Position Relative Move tool fixes
- corrected copyright headers - code formatting - made dialog pointer private, added UpdateAnchor() and modified click handler routine accordingly - renamed .fbp file to match other dialogs pattern
This commit is contained in:
parent
aeb23188f1
commit
fc58bd3848
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 John Beard, john.j.beard@gmail.com
|
||||
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017 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
|
||||
|
@ -187,7 +186,7 @@ void DIALOG_POSITION_RELATIVE::OnSelectItemClick( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_POSITION_RELATIVE::UpdateAchor( BOARD_ITEM* aBoardItem )
|
||||
void DIALOG_POSITION_RELATIVE::UpdateAnchor( BOARD_ITEM* aBoardItem )
|
||||
{
|
||||
m_anchor_position = aBoardItem->GetPosition();
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 John Beard, john.j.beard@gmail.com
|
||||
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017 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
|
||||
|
@ -47,7 +46,7 @@ public:
|
|||
double& rotation, wxPoint& anchorposition );
|
||||
~DIALOG_POSITION_RELATIVE();
|
||||
|
||||
void UpdateAchor( BOARD_ITEM* aBoardItem );
|
||||
void UpdateAnchor( BOARD_ITEM* aBoardItem );
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2015 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* Copyright (C) 2017 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
|
||||
|
@ -90,8 +88,10 @@ TOOL_ACTION PCB_ACTIONS::selectpositionRelativeItem(
|
|||
"",
|
||||
nullptr );
|
||||
|
||||
|
||||
POSITION_RELATIVE_TOOL::POSITION_RELATIVE_TOOL() :
|
||||
PCB_TOOL( "pcbnew.PositionRelative" ), m_selectionTool( NULL )
|
||||
PCB_TOOL( "pcbnew.PositionRelative" ), m_position_relative_dialog( NULL ),
|
||||
m_selectionTool( NULL ), m_anchor_item( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,6 @@ bool POSITION_RELATIVE_TOOL::Init()
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -136,7 +135,6 @@ int POSITION_RELATIVE_TOOL::PositionRelative( const TOOL_EVENT& aEvent )
|
|||
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
|
||||
m_position_relative_rotation = 0;
|
||||
|
||||
|
||||
if( !m_position_relative_dialog )
|
||||
m_position_relative_dialog = new DIALOG_POSITION_RELATIVE( editFrame,
|
||||
m_toolMgr,
|
||||
|
@ -150,15 +148,12 @@ int POSITION_RELATIVE_TOOL::PositionRelative( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
static bool selectPRitem( TOOL_MANAGER* aToolMgr,
|
||||
BOARD_ITEM* m_anchor_item,
|
||||
const VECTOR2D& aPosition )
|
||||
static bool selectPRitem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
||||
{
|
||||
SELECTION_TOOL* selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
|
||||
POSITION_RELATIVE_TOOL* positionRelativeTool = aToolMgr->GetTool<POSITION_RELATIVE_TOOL>();
|
||||
|
||||
assert( selectionTool );
|
||||
assert( positionRelativeTool );
|
||||
wxCHECK( selectionTool, false );
|
||||
wxCHECK( positionRelativeTool, false );
|
||||
|
||||
aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
||||
|
@ -169,18 +164,12 @@ static bool selectPRitem( TOOL_MANAGER* aToolMgr,
|
|||
if( selection.Empty() )
|
||||
return true;
|
||||
|
||||
m_anchor_item = static_cast<BOARD_ITEM*>( selection.Front() );
|
||||
positionRelativeTool->m_position_relative_dialog->UpdateAchor( m_anchor_item );
|
||||
positionRelativeTool->UpdateAnchor( static_cast<BOARD_ITEM*>( selection.Front() ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOARD_ITEM* POSITION_RELATIVE_TOOL::GetAnchorItem()
|
||||
{
|
||||
return m_anchor_item;
|
||||
}
|
||||
|
||||
|
||||
int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( wxPoint anchorPosition,
|
||||
wxPoint relativePosition,
|
||||
double rotation )
|
||||
|
@ -215,7 +204,7 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
|
|||
assert( picker );
|
||||
|
||||
picker->SetSnapping( false );
|
||||
picker->SetClickHandler( std::bind( selectPRitem, m_toolMgr, m_anchor_item, _1 ) );
|
||||
picker->SetClickHandler( std::bind( selectPRitem, m_toolMgr, _1 ) );
|
||||
picker->Activate();
|
||||
Wait();
|
||||
|
||||
|
@ -223,6 +212,15 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
|
|||
}
|
||||
|
||||
|
||||
void POSITION_RELATIVE_TOOL::UpdateAnchor( BOARD_ITEM* aItem )
|
||||
{
|
||||
m_anchor_item = aItem;
|
||||
|
||||
if( m_position_relative_dialog )
|
||||
m_position_relative_dialog->UpdateAnchor( aItem );
|
||||
}
|
||||
|
||||
|
||||
void POSITION_RELATIVE_TOOL::SetTransitions()
|
||||
{
|
||||
Go( &POSITION_RELATIVE_TOOL::PositionRelative, PCB_ACTIONS::positionRelative.MakeEvent() );
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2015 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* Copyright (C) 2017 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
|
||||
|
@ -49,12 +47,11 @@ class POSITION_RELATIVE_TOOL : public PCB_TOOL
|
|||
public:
|
||||
POSITION_RELATIVE_TOOL();
|
||||
|
||||
void Reset( RESET_REASON aReason );
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
/// @copydoc POSITION_RELATIVE_TOOL::Init()
|
||||
bool Init() override;
|
||||
|
||||
|
||||
/**
|
||||
* Function PositionRelative()
|
||||
*
|
||||
|
@ -82,18 +79,27 @@ public:
|
|||
*
|
||||
* Gets the last selected anchor item.
|
||||
*/
|
||||
BOARD_ITEM* GetAnchorItem();
|
||||
BOARD_ITEM* GetAnchorItem()
|
||||
{
|
||||
return m_anchor_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function UpdateAnchor()
|
||||
*
|
||||
* Selects the item to be used as the reference for relative move operation.
|
||||
*/
|
||||
void UpdateAnchor( BOARD_ITEM* aItem );
|
||||
|
||||
///> Sets up handlers for various events.
|
||||
void SetTransitions() override;
|
||||
|
||||
private:
|
||||
DIALOG_POSITION_RELATIVE* m_position_relative_dialog;
|
||||
|
||||
private:
|
||||
///> Selection tool used for obtaining selected items
|
||||
SELECTION_TOOL* m_selectionTool;
|
||||
|
||||
|
||||
std::unique_ptr<BOARD_COMMIT> m_commit;
|
||||
|
||||
///> Last anchor item selected by Position Relative To function.
|
||||
|
|
Loading…
Reference in New Issue