Formatting and organisation.
This commit is contained in:
parent
21d4197eab
commit
e50b450092
|
@ -426,39 +426,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
BOARD_ITEM* text = NULL;
|
BOARD_ITEM* text = NULL;
|
||||||
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
||||||
BOARD_COMMIT commit( m_frame );
|
BOARD_COMMIT commit( m_frame );
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
||||||
m_controls->ShowCursor( true );
|
|
||||||
// do not capture or auto-pan until we start placing some text
|
|
||||||
|
|
||||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
// Prime the pump
|
|
||||||
if( !aEvent.IsReactivate() )
|
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
|
||||||
|
|
||||||
auto setCursor =
|
|
||||||
[&]()
|
|
||||||
{
|
|
||||||
if( text )
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
|
||||||
else
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set initial cursor
|
|
||||||
setCursor();
|
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
|
||||||
{
|
|
||||||
setCursor();
|
|
||||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
|
||||||
|
|
||||||
auto cleanup =
|
auto cleanup =
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
|
@ -471,10 +440,42 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
text = NULL;
|
text = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto setCursor =
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
if( text )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||||
|
else
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
|
||||||
|
};
|
||||||
|
|
||||||
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
m_controls->ShowCursor( true );
|
||||||
|
// do not capture or auto-pan until we start placing some text
|
||||||
|
|
||||||
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
|
m_frame->PushTool( tool );
|
||||||
|
Activate();
|
||||||
|
|
||||||
|
// Prime the pump
|
||||||
|
if( !aEvent.IsReactivate() )
|
||||||
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
|
// Set initial cursor
|
||||||
|
setCursor();
|
||||||
|
|
||||||
|
// Main loop: keep receiving events
|
||||||
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
|
{
|
||||||
|
setCursor();
|
||||||
|
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
if( text )
|
if( text )
|
||||||
|
{
|
||||||
cleanup();
|
cleanup();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( tool );
|
||||||
|
@ -648,27 +649,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
if( m_isFootprintEditor && !m_frame->GetModel() )
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TOOL_EVENT originalEvent = aEvent;
|
|
||||||
DIMENSION_BASE* dimension = nullptr;
|
|
||||||
BOARD_COMMIT commit( m_frame );
|
|
||||||
PCB_GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() );
|
|
||||||
|
|
||||||
const BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
|
|
||||||
|
|
||||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
|
||||||
PCB_SELECTION preview;
|
|
||||||
|
|
||||||
m_view->Add( &preview );
|
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
||||||
m_controls->ShowCursor( true );
|
|
||||||
|
|
||||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
|
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
enum DIMENSION_STEPS
|
enum DIMENSION_STEPS
|
||||||
{
|
{
|
||||||
SET_ORIGIN = 0,
|
SET_ORIGIN = 0,
|
||||||
|
@ -676,13 +656,31 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
SET_HEIGHT,
|
SET_HEIGHT,
|
||||||
FINISHED
|
FINISHED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TOOL_EVENT originalEvent = aEvent;
|
||||||
|
DIMENSION_BASE* dimension = nullptr;
|
||||||
|
BOARD_COMMIT commit( m_frame );
|
||||||
|
PCB_GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() );
|
||||||
|
BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
|
||||||
|
PCB_SELECTION preview; // A VIEW_GROUP that serves as a preview for the new item(s)
|
||||||
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
|
||||||
int step = SET_ORIGIN;
|
int step = SET_ORIGIN;
|
||||||
|
|
||||||
// Prime the pump
|
m_view->Add( &preview );
|
||||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
|
||||||
|
|
||||||
if( aEvent.HasPosition() )
|
auto cleanup =
|
||||||
m_toolMgr->PrimeTool( aEvent.Position() );
|
[&]()
|
||||||
|
{
|
||||||
|
m_controls->SetAutoPan( false );
|
||||||
|
m_controls->CaptureCursor( false );
|
||||||
|
|
||||||
|
preview.Clear();
|
||||||
|
m_view->Update( &preview );
|
||||||
|
|
||||||
|
delete dimension;
|
||||||
|
dimension = nullptr;
|
||||||
|
step = SET_ORIGIN;
|
||||||
|
};
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -690,6 +688,19 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
m_controls->ShowCursor( true );
|
||||||
|
|
||||||
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
|
m_frame->PushTool( tool );
|
||||||
|
Activate();
|
||||||
|
|
||||||
|
// Prime the pump
|
||||||
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||||
|
|
||||||
|
if( aEvent.HasPosition() )
|
||||||
|
m_toolMgr->PrimeTool( aEvent.Position() );
|
||||||
|
|
||||||
// Set initial cursor
|
// Set initial cursor
|
||||||
setCursor();
|
setCursor();
|
||||||
|
|
||||||
|
@ -709,20 +720,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
cursorPos = grid.BestSnapAnchor( cursorPos, nullptr );
|
cursorPos = grid.BestSnapAnchor( cursorPos, nullptr );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
m_controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
auto cleanup =
|
|
||||||
[&]()
|
|
||||||
{
|
|
||||||
m_controls->SetAutoPan( false );
|
|
||||||
m_controls->CaptureCursor( false );
|
|
||||||
|
|
||||||
preview.Clear();
|
|
||||||
m_view->Update( &preview );
|
|
||||||
|
|
||||||
delete dimension;
|
|
||||||
dimension = nullptr;
|
|
||||||
step = SET_ORIGIN;
|
|
||||||
};
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
m_controls->SetAutoPan( false );
|
m_controls->SetAutoPan( false );
|
||||||
|
|
Loading…
Reference in New Issue