Fix botched attempt to have ruler adjust to unit changes.
Also fixes the context menu so there's a specific one for the measurement tool, allowing zooming for instance without cancelling the tool.
This commit is contained in:
parent
16b5f40817
commit
afd80c3cdb
|
@ -71,9 +71,12 @@ public:
|
||||||
return wxT( "RULER_ITEM" );
|
return wxT( "RULER_ITEM" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateUserUnits( EDA_UNITS_T aUserUnits )
|
void SwitchUnits()
|
||||||
{
|
{
|
||||||
m_userUnits = aUserUnits;
|
if( m_userUnits == INCHES )
|
||||||
|
m_userUnits = MILLIMETRES;
|
||||||
|
else
|
||||||
|
m_userUnits = INCHES;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <tools/pcb_actions.h>
|
|
||||||
|
|
||||||
void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
|
void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
|
||||||
{
|
{
|
||||||
|
@ -81,13 +81,3 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
|
||||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
|
||||||
{
|
|
||||||
PCB_BASE_FRAME::unitsChangeRefresh(); // Update the status bar.
|
|
||||||
|
|
||||||
GetToolManager()->RunAction( PCB_ACTIONS::switchUnits, true ); // Notify tools.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -204,8 +204,6 @@ protected:
|
||||||
* duplicateItem(BOARD_ITEM*, bool) above
|
* duplicateItem(BOARD_ITEM*, bool) above
|
||||||
*/
|
*/
|
||||||
virtual void duplicateItems( bool aIncrement ) = 0;
|
virtual void duplicateItems( bool aIncrement ) = 0;
|
||||||
|
|
||||||
void unitsChangeRefresh() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -237,7 +237,8 @@ void EnsureEditableFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector )
|
||||||
|
|
||||||
EDIT_TOOL::EDIT_TOOL() :
|
EDIT_TOOL::EDIT_TOOL() :
|
||||||
PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
|
PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
|
||||||
m_dragging( false )
|
m_dragging( false ),
|
||||||
|
m_measureMenu( *this )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +319,16 @@ bool EDIT_TOOL::Init()
|
||||||
menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition );
|
menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition );
|
||||||
menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition );
|
menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition );
|
||||||
|
|
||||||
|
// Initialize menu for Measurement Tool
|
||||||
|
auto& ctxMenu = m_measureMenu.GetMenu();
|
||||||
|
|
||||||
|
// cancel current toool goes in main context menu at the top if present
|
||||||
|
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1000 );
|
||||||
|
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 );
|
||||||
|
|
||||||
|
// Finally, add the standard zoom/grid items
|
||||||
|
m_measureMenu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,7 +1212,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||||
|
|
||||||
if( evt->IsCancel() || evt->IsActivate() )
|
if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1255,7 +1266,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
else if( evt->IsAction( &PCB_ACTIONS::switchUnits ) )
|
else if( evt->IsAction( &PCB_ACTIONS::switchUnits ) )
|
||||||
{
|
{
|
||||||
ruler.UpdateUserUnits( frame()->GetUserUnits() );
|
ruler.SwitchUnits();
|
||||||
|
|
||||||
view.SetVisible( &ruler, true );
|
view.SetVisible( &ruler, true );
|
||||||
view.Update( &ruler, KIGFX::GEOMETRY );
|
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||||
|
@ -1263,7 +1274,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
{
|
{
|
||||||
GetManager()->PassEvent();
|
m_measureMenu.ShowContextMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,9 @@ private:
|
||||||
///> of edit reference point).
|
///> of edit reference point).
|
||||||
VECTOR2I m_cursor;
|
VECTOR2I m_cursor;
|
||||||
|
|
||||||
|
///> A context menu for the Measurement Tool
|
||||||
|
TOOL_MENU m_measureMenu;
|
||||||
|
|
||||||
///> 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.
|
||||||
bool updateModificationPoint( SELECTION& aSelection );
|
bool updateModificationPoint( SELECTION& aSelection );
|
||||||
|
|
Loading…
Reference in New Issue