Moved SELECTION out of SELECTION_TOOL class.
This commit is contained in:
parent
d21271b432
commit
bfa15d8db0
|
@ -73,7 +73,7 @@ bool EDIT_TOOL::Init()
|
||||||
|
|
||||||
int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
// Shall the selection be cleared at the end?
|
// Shall the selection be cleared at the end?
|
||||||
bool unselect = selection.Empty();
|
bool unselect = selection.Empty();
|
||||||
|
@ -218,7 +218,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||||
|
|
||||||
if( !makeSelection( selection ) )
|
if( !makeSelection( selection ) )
|
||||||
|
@ -287,7 +287,7 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||||
|
|
||||||
// Shall the selection be cleared at the end?
|
// Shall the selection be cleared at the end?
|
||||||
|
@ -341,7 +341,7 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
|
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
|
||||||
|
|
||||||
// Shall the selection be cleared at the end?
|
// Shall the selection be cleared at the end?
|
||||||
|
@ -395,7 +395,7 @@ int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( !makeSelection( selection ) )
|
if( !makeSelection( selection ) )
|
||||||
{
|
{
|
||||||
|
@ -522,7 +522,7 @@ void EDIT_TOOL::setTransitions()
|
||||||
|
|
||||||
void EDIT_TOOL::updateRatsnest( bool aRedraw )
|
void EDIT_TOOL::updateRatsnest( bool aRedraw )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
|
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
|
||||||
|
|
||||||
ratsnest->ClearSimple();
|
ratsnest->ClearSimple();
|
||||||
|
@ -538,7 +538,7 @@ void EDIT_TOOL::updateRatsnest( bool aRedraw )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxPoint EDIT_TOOL::getModificationPoint( const SELECTION_TOOL::SELECTION& aSelection )
|
wxPoint EDIT_TOOL::getModificationPoint( const SELECTION& aSelection )
|
||||||
{
|
{
|
||||||
if( aSelection.Size() == 1 )
|
if( aSelection.Size() == 1 )
|
||||||
{
|
{
|
||||||
|
@ -556,7 +556,7 @@ wxPoint EDIT_TOOL::getModificationPoint( const SELECTION_TOOL::SELECTION& aSelec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EDIT_TOOL::makeSelection( const SELECTION_TOOL::SELECTION& aSelection )
|
bool EDIT_TOOL::makeSelection( const SELECTION& aSelection )
|
||||||
{
|
{
|
||||||
if( aSelection.Empty() ) // Try to find an item that could be modified
|
if( aSelection.Empty() ) // Try to find an item that could be modified
|
||||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionSingle );
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionSingle );
|
||||||
|
|
|
@ -143,11 +143,11 @@ 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.
|
||||||
wxPoint getModificationPoint( const SELECTION_TOOL::SELECTION& aSelection );
|
wxPoint getModificationPoint( const SELECTION& aSelection );
|
||||||
|
|
||||||
///> If there are no items currently selected, it tries to choose the item that is under
|
///> If there are no items currently selected, it tries to choose the item that is under
|
||||||
///> the cursor or displays a disambiguation menu if there are multpile items.
|
///> the cursor or displays a disambiguation menu if there are multpile items.
|
||||||
bool makeSelection( const SELECTION_TOOL::SELECTION& aSelection );
|
bool makeSelection( const SELECTION& aSelection );
|
||||||
|
|
||||||
///> Updates view with the changes in the list.
|
///> Updates view with the changes in the list.
|
||||||
void processChanges( const PICKED_ITEMS_LIST* aList );
|
void processChanges( const PICKED_ITEMS_LIST* aList );
|
||||||
|
|
|
@ -329,7 +329,7 @@ int MODULE_TOOLS::EnumeratePads( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
|
int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
|
const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool PLACEMENT_TOOL::Init()
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignTop( TOOL_EVENT& aEvent )
|
int PLACEMENT_TOOL::AlignTop( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( selection.Size() > 1 )
|
if( selection.Size() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ int PLACEMENT_TOOL::AlignTop( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignBottom( TOOL_EVENT& aEvent )
|
int PLACEMENT_TOOL::AlignBottom( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( selection.Size() > 1 )
|
if( selection.Size() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,7 @@ int PLACEMENT_TOOL::AlignBottom( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignLeft( TOOL_EVENT& aEvent )
|
int PLACEMENT_TOOL::AlignLeft( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( selection.Size() > 1 )
|
if( selection.Size() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -202,7 +202,7 @@ int PLACEMENT_TOOL::AlignLeft( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignRight( TOOL_EVENT& aEvent )
|
int PLACEMENT_TOOL::AlignRight( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( selection.Size() > 1 )
|
if( selection.Size() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -257,7 +257,7 @@ static bool compareY( const BOARD_ITEM* aA, const BOARD_ITEM* aB )
|
||||||
|
|
||||||
int PLACEMENT_TOOL::DistributeHorizontally( TOOL_EVENT& aEvent )
|
int PLACEMENT_TOOL::DistributeHorizontally( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( selection.Size() > 1 )
|
if( selection.Size() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -306,7 +306,7 @@ int PLACEMENT_TOOL::DistributeHorizontally( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PLACEMENT_TOOL::DistributeVertically( TOOL_EVENT& aEvent )
|
int PLACEMENT_TOOL::DistributeVertically( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( selection.Size() > 1 )
|
if( selection.Size() > 1 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -203,7 +203,7 @@ bool POINT_EDITOR::Init()
|
||||||
|
|
||||||
int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
|
int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( selection.Size() == 1 )
|
if( selection.Size() == 1 )
|
||||||
{
|
{
|
||||||
|
@ -666,7 +666,7 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
|
||||||
void POINT_EDITOR::breakOutline( const VECTOR2I& aBreakPoint )
|
void POINT_EDITOR::breakOutline( const VECTOR2I& aBreakPoint )
|
||||||
{
|
{
|
||||||
EDA_ITEM* item = m_editPoints->GetParent();
|
EDA_ITEM* item = m_editPoints->GetParent();
|
||||||
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
if( item->Type() == PCB_ZONE_AREA_T )
|
if( item->Type() == PCB_ZONE_AREA_T )
|
||||||
{
|
{
|
||||||
|
|
|
@ -764,7 +764,7 @@ BOARD_ITEM* SELECTION_TOOL::prefer( GENERAL_COLLECTOR& aCollector, const KICAD_T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SELECTION_TOOL::SELECTION::clear()
|
void SELECTION::clear()
|
||||||
{
|
{
|
||||||
items.ClearItemsList();
|
items.ClearItemsList();
|
||||||
group->Clear();
|
group->Clear();
|
||||||
|
|
|
@ -41,26 +41,8 @@ namespace KIGFX
|
||||||
class VIEW_GROUP;
|
class VIEW_GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
struct SELECTION
|
||||||
* Class SELECTION_TOOL
|
|
||||||
*
|
|
||||||
* Our sample selection tool: currently supports:
|
|
||||||
* - pick single objects (click LMB)
|
|
||||||
* - add objects to existing selection (Shift+LMB)
|
|
||||||
* - draw selection box (drag LMB)
|
|
||||||
* - handles MODULEs properly (i.e. selects either MODULE or its PADs, TEXTs, etc.)
|
|
||||||
* - takes into account high-contrast & layer visibility settings
|
|
||||||
* - invokes InteractiveEdit tool when user starts to drag selected items
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SELECTION_TOOL : public TOOL_INTERACTIVE
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
SELECTION_TOOL();
|
|
||||||
~SELECTION_TOOL();
|
|
||||||
|
|
||||||
struct SELECTION
|
|
||||||
{
|
|
||||||
/// Set of selected items
|
/// Set of selected items
|
||||||
PICKED_ITEMS_LIST items;
|
PICKED_ITEMS_LIST items;
|
||||||
|
|
||||||
|
@ -86,13 +68,30 @@ public:
|
||||||
return static_cast<T*>( items.GetPickedItem( aIndex ) );
|
return static_cast<T*>( items.GetPickedItem( aIndex ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Clears both the VIEW_GROUP and set of selected items. Please note that it does not
|
/// Clears both the VIEW_GROUP and set of selected items. Please note that it does not
|
||||||
/// change properties of selected items (e.g. selection flag).
|
/// change properties of selected items (e.g. selection flag).
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
friend class SELECTION_TOOL;
|
friend class SELECTION_TOOL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SELECTION_TOOL
|
||||||
|
*
|
||||||
|
* Our sample selection tool: currently supports:
|
||||||
|
* - pick single objects (click LMB)
|
||||||
|
* - add objects to existing selection (Shift+LMB)
|
||||||
|
* - draw selection box (drag LMB)
|
||||||
|
* - handles MODULEs properly (i.e. selects either MODULE or its PADs, TEXTs, etc.)
|
||||||
|
* - takes into account high-contrast & layer visibility settings
|
||||||
|
* - invokes InteractiveEdit tool when user starts to drag selected items
|
||||||
|
*/
|
||||||
|
class SELECTION_TOOL : public TOOL_INTERACTIVE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SELECTION_TOOL();
|
||||||
|
~SELECTION_TOOL();
|
||||||
|
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
void Reset( RESET_REASON aReason );
|
void Reset( RESET_REASON aReason );
|
||||||
|
|
Loading…
Reference in New Issue