setTransitions() are called automatically for tools.

This commit is contained in:
Maciej Suminski 2015-04-30 10:46:03 +02:00
parent 6e45180b5a
commit 946b9d1933
18 changed files with 43 additions and 219 deletions

View File

@ -389,6 +389,7 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
}
aTool->Reset( TOOL_INTERACTIVE::RUN );
aTool->SetTransitions();
// Add the tool on the front of the processing queue (it gets events first)
m_activeTools.push_front( aTool->GetId() );
@ -425,7 +426,10 @@ void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason )
ProcessEvent( evt );
BOOST_FOREACH( TOOL_BASE* tool, m_toolState | boost::adaptors::map_keys )
{
tool->Reset( aReason );
tool->SetTransitions();
}
}
@ -621,6 +625,8 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
if( tool != m_activeTools.end() )
m_activeTools.erase( tool );
}
aState->theTool->SetTransitions();
}

View File

@ -140,6 +140,13 @@ public:
return m_toolMgr;
}
/**
* Function SetTransitions()
* This method is meant to be overridden in order to specify handlers for events. It is called
* every time tool is reset or finished.
*/
virtual void SetTransitions() {};
protected:
friend class TOOL_MANAGER;

View File

@ -66,8 +66,6 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
m_controls = getViewControls();
m_board = getModel<BOARD>();
m_frame = getEditFrame<PCB_EDIT_FRAME>();
setTransitions();
}
@ -124,7 +122,6 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
}
}
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -172,7 +169,6 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
}
}
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -220,7 +216,6 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
}
}
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -411,7 +406,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
m_controls->CaptureCursor( false );
m_view->Remove( &preview );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -442,11 +436,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
if( dlgResult != wxID_OK || m_board->m_Modules == NULL || list.empty() )
{
setTransitions();
return 0;
}
VECTOR2I cursorPos = m_controls->GetCursorPosition();
VECTOR2I delta = cursorPos - (*list.begin())->GetPosition();
@ -617,8 +607,6 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
m_controls->CaptureCursor( false );
m_view->Remove( &preview );
setTransitions();
return 0;
}
@ -663,7 +651,6 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
m_controls->SetSnapping( false );
m_controls->ShowCursor( false );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -1230,7 +1217,6 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
m_controls->CaptureCursor( false );
m_view->Remove( &preview );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -1351,7 +1337,6 @@ int DRAWING_TOOL::placeTextModule()
m_controls->CaptureCursor( true );
m_view->Remove( &preview );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -1461,7 +1446,6 @@ int DRAWING_TOOL::placeTextPcb()
m_controls->CaptureCursor( false );
m_view->Remove( &preview );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -1490,7 +1474,7 @@ void DRAWING_TOOL::make45DegLine( DRAWSEGMENT* aSegment, DRAWSEGMENT* aHelper )
}
void DRAWING_TOOL::setTransitions()
void DRAWING_TOOL::SetTransitions()
{
Go( &DRAWING_TOOL::DrawLine, COMMON_ACTIONS::drawLine.MakeEvent() );
Go( &DRAWING_TOOL::DrawCircle, COMMON_ACTIONS::drawCircle.MakeEvent() );

View File

@ -132,6 +132,9 @@ public:
m_editModules = aEnabled;
}
///> Sets up handlers for various events.
void SetTransitions();
private:
///> Starts drawing a selected shape (i.e. DRAWSEGMENT).
///> @param aShape is the type of created shape (@see STROKE_T).
@ -176,9 +179,6 @@ private:
*/
void make45DegLine( DRAWSEGMENT* aSegment, DRAWSEGMENT* aHelper ) const;
///> Sets up handlers for various events.
void setTransitions();
///> Returns the appropriate width for a segment depending on the settings.
int getSegmentWidth( unsigned int aLayer ) const;

View File

@ -96,8 +96,6 @@ bool EDIT_TOOL::Init()
m_offset.x = 0;
m_offset.y = 0;
setTransitions();
return true;
}
@ -128,10 +126,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
// Be sure that there is at least one item that we can modify. If nothing was selected before,
// try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
if( !hoverSelection( selection ) )
{
setTransitions();
return 0;
}
Activate();
@ -345,8 +340,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
controls->SetAutoPan( false );
controls->ForceCursorPosition( false );
setTransitions();
return 0;
}
@ -357,11 +350,7 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
if( !hoverSelection( selection, false ) )
{
setTransitions();
return 0;
}
// Properties are displayed when there is only one item selected
if( selection.Size() == 1 )
@ -398,8 +387,6 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
item->SetFlags( flags );
}
setTransitions();
return 0;
}
@ -413,11 +400,7 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
bool unselect = selection.Empty();
if( !hoverSelection( selection ) )
{
setTransitions();
return 0;
}
wxPoint rotatePoint = getModificationPoint( selection );
@ -453,7 +436,6 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
setTransitions();
return 0;
}
@ -468,11 +450,7 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
bool unselect = selection.Empty();
if( !hoverSelection( selection ) )
{
setTransitions();
return 0;
}
wxPoint flipPoint = getModificationPoint( selection );
@ -507,7 +485,6 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
setTransitions();
return 0;
}
@ -518,11 +495,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
const SELECTION& selection = m_selectionTool->GetSelection();
if( !hoverSelection( selection ) )
{
setTransitions();
return 0;
}
// Get a copy of the selected items set
PICKED_ITEMS_LIST selectedItems = selection.items;
@ -544,8 +517,6 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
getModel<BOARD>()->GetRatsnest()->Recalculate();
setTransitions();
return 0;
}
@ -655,11 +626,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
bool unselect = selection.Empty();
if( !hoverSelection( selection ) )
{
setTransitions();
return 0;
}
wxPoint translation;
double rotation = 0;
@ -705,8 +672,6 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
}
setTransitions();
return 0;
}
@ -721,10 +686,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
// Be sure that there is at least one item that we can modify
if( !hoverSelection( selection ) )
{
setTransitions();
return 0;
}
// we have a selection to work on now, so start the tool process
@ -803,8 +765,6 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
// and re-enable undos
decUndoInhibit();
setTransitions();
return 0;
}
@ -817,10 +777,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
// Be sure that there is at least one item that we can modify
if( !hoverSelection( selection ) )
{
setTransitions();
return 0;
}
bool originalItemsModified = false;
@ -980,13 +937,12 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
}
getModel<BOARD>()->GetRatsnest()->Recalculate();
setTransitions();
return 0;
}
void EDIT_TOOL::setTransitions()
void EDIT_TOOL::SetTransitions()
{
Go( &EDIT_TOOL::Main, COMMON_ACTIONS::editActivate.MakeEvent() );
Go( &EDIT_TOOL::Rotate, COMMON_ACTIONS::rotate.MakeEvent() );
@ -1125,6 +1081,5 @@ int EDIT_TOOL::editFootprintInFpEditor( const TOOL_EVENT& aEvent )
editor->Show( true );
editor->Raise(); // Iconize( false );
setTransitions();
return 0;
}

View File

@ -126,6 +126,9 @@ public:
m_editModules = aEnabled;
}
///> Sets up handlers for various events.
void SetTransitions();
private:
///> Selection tool used for obtaining selected items
SELECTION_TOOL* m_selectionTool;
@ -149,9 +152,6 @@ private:
///> Removes and frees a single BOARD_ITEM.
void remove( BOARD_ITEM* aItem );
///> Sets up handlers for various events.
void setTransitions();
///> The required update flag for modified items
KIGFX::VIEW_ITEM::VIEW_UPDATE_FLAGS m_updateFlag;

View File

@ -76,8 +76,6 @@ bool MODULE_TOOLS::Init()
selectionTool->AddMenuItem( COMMON_ACTIONS::enumeratePads );
setTransitions();
return true;
}
@ -170,7 +168,6 @@ int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
m_controls->SetAutoPan( false );
m_view->Remove( &preview );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -200,11 +197,7 @@ int MODULE_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
DIALOG_ENUM_PADS settingsDlg( m_frame );
if( settingsDlg.ShowModal() == wxID_CANCEL )
{
setTransitions();
return 0;
}
int padNumber = settingsDlg.GetStartNumber();
wxString padPrefix = settingsDlg.GetPrefix();
@ -312,8 +305,6 @@ int MODULE_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
m_frame->DisplayToolMsg( wxEmptyString );
m_controls->ShowCursor( false );
setTransitions();
return 0;
}
@ -384,8 +375,6 @@ int MODULE_TOOLS::CopyItems( const TOOL_EVENT& aEvent )
m_controls->ShowCursor( false );
m_controls->SetAutoPan( false );
setTransitions();
return 0;
}
@ -406,8 +395,6 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
catch( ... )
{
m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
setTransitions();
return 0;
}
@ -516,8 +503,6 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
m_controls->SetAutoPan( false );
m_view->Remove( &preview );
setTransitions();
return 0;
}
@ -553,7 +538,6 @@ int MODULE_TOOLS::ModuleTextOutlines( const TOOL_EVENT& aEvent )
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
}
@ -585,13 +569,12 @@ int MODULE_TOOLS::ModuleEdgeOutlines( const TOOL_EVENT& aEvent )
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
}
void MODULE_TOOLS::setTransitions()
void MODULE_TOOLS::SetTransitions()
{
Go( &MODULE_TOOLS::PlacePad, COMMON_ACTIONS::placePad.MakeEvent() );
Go( &MODULE_TOOLS::EnumeratePads, COMMON_ACTIONS::enumeratePads.MakeEvent() );

View File

@ -98,10 +98,10 @@ public:
*/
int ModuleEdgeOutlines( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions();
void SetTransitions();
private:
KIGFX::VIEW* m_view;
KIGFX::VIEW_CONTROLS* m_controls;
BOARD* m_board;

View File

@ -78,8 +78,6 @@ bool PCB_EDITOR_CONTROL::Init()
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
}
setTransitions();
return true;
}
@ -98,8 +96,6 @@ int PCB_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent )
wxUpdateUIEvent dummy;
m_frame->OnUpdateSelectTrackWidth( dummy );
setTransitions();
m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
return 0;
@ -119,8 +115,6 @@ int PCB_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent )
wxUpdateUIEvent dummy;
m_frame->OnUpdateSelectTrackWidth( dummy );
setTransitions();
m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
return 0;
@ -140,8 +134,6 @@ int PCB_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent )
wxUpdateUIEvent dummy;
m_frame->OnUpdateSelectViaSize( dummy );
setTransitions();
m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
return 0;
@ -161,8 +153,6 @@ int PCB_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent )
wxUpdateUIEvent dummy;
m_frame->OnUpdateSelectViaSize( dummy );
setTransitions();
m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
return 0;
@ -277,7 +267,6 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
controls->CaptureCursor( false );
view->Remove( &preview );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -370,7 +359,6 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
controls->CaptureCursor( false );
view->Remove( &preview );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -393,8 +381,6 @@ int PCB_EDITOR_CONTROL::ZoneFill( const TOOL_EVENT& aEvent )
zone->ViewUpdate();
}
setTransitions();
return 0;
}
@ -411,8 +397,6 @@ int PCB_EDITOR_CONTROL::ZoneFillAll( const TOOL_EVENT& aEvent )
zone->ViewUpdate();
}
setTransitions();
return 0;
}
@ -432,8 +416,6 @@ int PCB_EDITOR_CONTROL::ZoneUnfill( const TOOL_EVENT& aEvent )
zone->ViewUpdate();
}
setTransitions();
return 0;
}
@ -450,8 +432,6 @@ int PCB_EDITOR_CONTROL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
zone->ViewUpdate();
}
setTransitions();
return 0;
}
@ -464,13 +444,11 @@ int PCB_EDITOR_CONTROL::SelectionCrossProbe( const TOOL_EVENT& aEvent )
if( selection.Size() == 1 )
m_frame->SendMessageToEESCHEMA( selection.Item<BOARD_ITEM>( 0 ) );
setTransitions();
return 0;
}
void PCB_EDITOR_CONTROL::setTransitions()
void PCB_EDITOR_CONTROL::SetTransitions()
{
// Track & via size control
Go( &PCB_EDITOR_CONTROL::TrackWidthInc, COMMON_ACTIONS::trackWidthInc.MakeEvent() );

View File

@ -72,10 +72,10 @@ public:
///> Notifies eeschema about the selected item.
int SelectionCrossProbe( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions();
void SetTransitions();
private:
///> Pointer to the currently used edit frame.
PCB_EDIT_FRAME* m_frame;

View File

@ -52,14 +52,6 @@ void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
}
bool PCBNEW_CONTROL::Init()
{
setTransitions();
return true;
}
int PCBNEW_CONTROL::ZoomInOut( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
@ -71,7 +63,6 @@ int PCBNEW_CONTROL::ZoomInOut( const TOOL_EVENT& aEvent )
zoomScale = 0.7;
view->SetScale( view->GetScale() * zoomScale, getViewControls()->GetCursorPosition() );
setTransitions();
return 0;
}
@ -88,7 +79,6 @@ int PCBNEW_CONTROL::ZoomInOutCenter( const TOOL_EVENT& aEvent )
zoomScale = 0.7;
view->SetScale( view->GetScale() * zoomScale );
setTransitions();
return 0;
}
@ -98,7 +88,6 @@ int PCBNEW_CONTROL::ZoomCenter( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
view->SetCenter( getViewControls()->GetCursorPosition() );
setTransitions();
return 0;
}
@ -134,8 +123,6 @@ int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
view->SetCenter( boardBBox.Centre() );
}
setTransitions();
return 0;
}
@ -150,21 +137,14 @@ int PCBNEW_CONTROL::ZoomPreset( const TOOL_EVENT& aEvent )
m_frame->SetPresetZoom( idx );
if( idx == 0 )
{
return ZoomFitScreen( aEvent );
}
else if( idx < 0 || idx >= zoomList.size() )
{
setTransitions();
return 0;
}
double selectedZoom = zoomList[idx];
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
view->SetScale( 1.0 / ( zoomFactor * selectedZoom ) );
setTransitions();
return 0;
}
@ -188,7 +168,6 @@ int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
}
@ -213,7 +192,6 @@ int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
}
@ -238,7 +216,6 @@ int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
}
@ -269,7 +246,6 @@ int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
board->GetArea( i )->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
}
@ -287,8 +263,6 @@ int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
settings->LoadDisplayOptions( displ_opts );
m_frame->GetGalCanvas()->SetHighContrastLayer( m_frame->GetActiveLayer() );
setTransitions();
return 0;
}
@ -296,7 +270,6 @@ int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::HighContrastInc( const TOOL_EVENT& aEvent )
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
setTransitions();
return 0;
}
@ -305,7 +278,6 @@ int PCBNEW_CONTROL::HighContrastInc( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::HighContrastDec( const TOOL_EVENT& aEvent )
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
setTransitions();
return 0;
}
@ -315,7 +287,6 @@ int PCBNEW_CONTROL::HighContrastDec( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerSwitch( const TOOL_EVENT& aEvent )
{
m_frame->SwitchLayer( NULL, (LAYER_ID) aEvent.Parameter<long>() );
setTransitions();
return 0;
}
@ -327,10 +298,7 @@ int PCBNEW_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
LAYER_NUM layer = editFrame->GetActiveLayer();
if( layer < F_Cu || layer > B_Cu )
{
setTransitions();
return 0;
}
int layerCount = getModel<BOARD>()->GetCopperLayerCount();
@ -343,7 +311,6 @@ int PCBNEW_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
assert( IsCopperLayer( layer ) );
editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
setTransitions();
return 0;
}
@ -355,10 +322,7 @@ int PCBNEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
LAYER_NUM layer = editFrame->GetActiveLayer();
if( layer < F_Cu || layer > B_Cu )
{
setTransitions();
return 0;
}
int layerCount = getModel<BOARD>()->GetCopperLayerCount();
@ -371,7 +335,6 @@ int PCBNEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
assert( IsCopperLayer( layer ) );
editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
setTransitions();
return 0;
}
@ -394,8 +357,6 @@ int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
}
setTransitions();
return 0;
}
@ -417,8 +378,6 @@ int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
}
setTransitions();
return 0;
}
@ -427,7 +386,6 @@ int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridFast1( const TOOL_EVENT& aEvent )
{
m_frame->SetFastGrid1();
setTransitions();
return 0;
}
@ -436,7 +394,6 @@ int PCBNEW_CONTROL::GridFast1( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridFast2( const TOOL_EVENT& aEvent )
{
m_frame->SetFastGrid2();
setTransitions();
return 0;
}
@ -445,7 +402,6 @@ int PCBNEW_CONTROL::GridFast2( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridNext( const TOOL_EVENT& aEvent )
{
m_frame->SetNextGrid();
setTransitions();
return 0;
}
@ -454,7 +410,6 @@ int PCBNEW_CONTROL::GridNext( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridPrev( const TOOL_EVENT& aEvent )
{
m_frame->SetPrevGrid();
setTransitions();
return 0;
}
@ -485,7 +440,6 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
controls->SetAutoPan( false );
controls->SetSnapping( false );
controls->ShowCursor( false );
setTransitions();
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -499,7 +453,6 @@ int PCBNEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar();
setTransitions();
return 0;
}
@ -517,8 +470,6 @@ int PCBNEW_CONTROL::SwitchCursor( const TOOL_EVENT& aEvent )
else
gal->SetCursorSize( BIG_CURSOR );
setTransitions();
return 0;
}
@ -534,7 +485,6 @@ int PCBNEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( evt );
setTransitions();
return 0;
}
@ -544,7 +494,6 @@ int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
{
// TODO
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
setTransitions();
return 0;
}
@ -553,13 +502,12 @@ int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent )
{
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
setTransitions();
return 0;
}
void PCBNEW_CONTROL::setTransitions()
void PCBNEW_CONTROL::SetTransitions()
{
// View controls
Go( &PCBNEW_CONTROL::ZoomInOut, COMMON_ACTIONS::zoomIn.MakeEvent() );
@ -601,6 +549,7 @@ void PCBNEW_CONTROL::setTransitions()
Go( &PCBNEW_CONTROL::GridNext, COMMON_ACTIONS::gridNext.MakeEvent() );
Go( &PCBNEW_CONTROL::GridPrev, COMMON_ACTIONS::gridPrev.MakeEvent() );
Go( &PCBNEW_CONTROL::GridSetOrigin, COMMON_ACTIONS::gridSetOrigin.MakeEvent() );
//Go( &PCBNEW_CONTROL::GridSetPreset, COMMON_ACTIONS::gridSetPreset.MakeEvent() );
// Miscellaneous
Go( &PCBNEW_CONTROL::ResetCoords, COMMON_ACTIONS::resetCoords.MakeEvent() );

View File

@ -43,9 +43,6 @@ public:
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason );
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init();
// View controls
int ZoomInOut( const TOOL_EVENT& aEvent );
int ZoomInOutCenter( const TOOL_EVENT& aEvent );
@ -83,10 +80,10 @@ public:
int ShowHelp( const TOOL_EVENT& aEvent );
int ToBeDone( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions();
void SetTransitions();
private:
///> Pointer to the currently used edit frame.
PCB_BASE_FRAME* m_frame;
};

View File

@ -66,8 +66,6 @@ bool PLACEMENT_TOOL::Init()
m_selectionTool->AddSubMenu( menu, _( "Align/distribute" ),
SELECTION_CONDITIONS::MoreThan( 1 ) );
setTransitions();
return true;
}
@ -109,8 +107,6 @@ int PLACEMENT_TOOL::AlignTop( const TOOL_EVENT& aEvent )
getModel<BOARD>()->GetRatsnest()->Recalculate();
}
setTransitions();
return 0;
}
@ -152,8 +148,6 @@ int PLACEMENT_TOOL::AlignBottom( const TOOL_EVENT& aEvent )
getModel<BOARD>()->GetRatsnest()->Recalculate();
}
setTransitions();
return 0;
}
@ -195,8 +189,6 @@ int PLACEMENT_TOOL::AlignLeft( const TOOL_EVENT& aEvent )
getModel<BOARD>()->GetRatsnest()->Recalculate();
}
setTransitions();
return 0;
}
@ -238,8 +230,6 @@ int PLACEMENT_TOOL::AlignRight( const TOOL_EVENT& aEvent )
getModel<BOARD>()->GetRatsnest()->Recalculate();
}
setTransitions();
return 0;
}
@ -299,8 +289,6 @@ int PLACEMENT_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent )
getModel<BOARD>()->GetRatsnest()->Recalculate();
}
setTransitions();
return 0;
}
@ -348,13 +336,11 @@ int PLACEMENT_TOOL::DistributeVertically( const TOOL_EVENT& aEvent )
getModel<BOARD>()->GetRatsnest()->Recalculate();
}
setTransitions();
return 0;
}
void PLACEMENT_TOOL::setTransitions()
void PLACEMENT_TOOL::SetTransitions()
{
Go( &PLACEMENT_TOOL::AlignTop, COMMON_ACTIONS::alignTop.MakeEvent() );
Go( &PLACEMENT_TOOL::AlignBottom, COMMON_ACTIONS::alignBottom.MakeEvent() );

View File

@ -77,10 +77,10 @@ public:
*/
int DistributeVertically( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions();
void SetTransitions();
private:
SELECTION_TOOL* m_selectionTool;
};

View File

@ -213,8 +213,6 @@ bool POINT_EDITOR::Init()
m_selectionTool->AddMenuItem( COMMON_ACTIONS::pointEditorBreakOutline,
POINT_EDITOR::breakOutlineCondition );
setTransitions();
return true;
}
@ -233,11 +231,9 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
EDA_ITEM* item = selection.items.GetPickedItem( 0 );
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
if( !m_editPoints )
{
setTransitions();
return 0;
}
view->Add( m_editPoints.get() );
m_dragPoint = NULL;
@ -363,8 +359,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
controls->ForceCursorPosition( false );
}
setTransitions();
return 0;
}
@ -795,7 +789,7 @@ void POINT_EDITOR::breakOutline( const VECTOR2I& aBreakPoint )
}
void POINT_EDITOR::setTransitions()
void POINT_EDITOR::SetTransitions()
{
Go( &POINT_EDITOR::OnSelectionChange, SELECTION_TOOL::SelectedEvent );
Go( &POINT_EDITOR::OnSelectionChange, SELECTION_TOOL::UnselectedEvent );

View File

@ -55,6 +55,9 @@ public:
*/
int OnSelectionChange( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void SetTransitions();
private:
///> Selection tool used for obtaining selected items
SELECTION_TOOL* m_selectionTool;
@ -98,9 +101,6 @@ private:
///> Adds a new edit point on a zone outline/line.
void breakOutline( const VECTOR2I& aBreakPoint );
///> Sets up handlers for various events.
void setTransitions();
///> Condition to display "Create corner" context menu entry.
static bool breakOutlineCondition( const SELECTION& aSelection );
};

View File

@ -106,8 +106,6 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW
getView()->Remove( m_selection.group );
getView()->Add( m_selection.group );
setTransitions();
}
@ -428,7 +426,7 @@ bool SELECTION_TOOL::selectMultiple()
}
void SELECTION_TOOL::setTransitions()
void SELECTION_TOOL::SetTransitions()
{
Go( &SELECTION_TOOL::Main, COMMON_ACTIONS::selectionActivate.MakeEvent() );
Go( &SELECTION_TOOL::CursorSelection, COMMON_ACTIONS::selectionCursor.MakeEvent() );
@ -492,7 +490,6 @@ SELECTION_LOCK_FLAGS SELECTION_TOOL::CheckLock()
int SELECTION_TOOL::CursorSelection( const TOOL_EVENT& aEvent )
{
selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ) );
setTransitions();
return 0;
}
@ -501,7 +498,6 @@ int SELECTION_TOOL::CursorSelection( const TOOL_EVENT& aEvent )
int SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent )
{
clearSelection();
setTransitions();
return 0;
}
@ -519,8 +515,6 @@ int SELECTION_TOOL::SelectItem( const TOOL_EVENT& aEvent )
m_toolMgr->ProcessEvent( SelectedEvent );
}
setTransitions();
return 0;
}
@ -537,8 +531,6 @@ int SELECTION_TOOL::UnselectItem( const TOOL_EVENT& aEvent )
m_toolMgr->ProcessEvent( UnselectedEvent );
}
setTransitions();
return 0;
}
@ -562,8 +554,6 @@ int SELECTION_TOOL::selectConnection( const TOOL_EVENT& aEvent )
m_toolMgr->ProcessEvent( selectEvent );
}
setTransitions();
return 0;
}
@ -588,8 +578,6 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
m_toolMgr->ProcessEvent( selectEvent );
}
setTransitions();
return 0;
}
@ -618,7 +606,6 @@ int SELECTION_TOOL::find( const TOOL_EVENT& aEvent )
dlg.EnableWarp( false );
dlg.SetCallback( boost::bind( &SELECTION_TOOL::findCallback, this, _1 ) );
dlg.ShowModal();
setTransitions();
return 0;
}
@ -635,8 +622,6 @@ int SELECTION_TOOL::findMove( const TOOL_EVENT& aEvent )
m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
}
setTransitions();
return 0;
}

View File

@ -185,6 +185,9 @@ public:
///> Event sent after selection is cleared.
static const TOOL_EVENT ClearedEvent;
///> Sets up handlers for various events.
void SetTransitions();
private:
/**
* Function selectCursor()
@ -221,9 +224,6 @@ private:
///> Find an item and start moving.
int findMove( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions();
/**
* Function clearSelection()
* Clears the current selection.