Added menu for locking tracks & vias (GAL).

This commit is contained in:
Maciej Suminski 2016-05-09 10:29:06 +02:00
parent dd10c577ec
commit ce8f400645
7 changed files with 112 additions and 18 deletions

View File

@ -199,7 +199,17 @@ public:
*/
virtual bool IsLocked() const
{
return false; // only MODULEs can be locked at this time.
// only MODULEs & TRACKs can be locked at this time.
return false;
}
/**
* Function SetLocked
* modifies 'lock' status for of the item.
*/
virtual void SetLocked( bool aLocked )
{
// only MODULEs & TRACKs can be locked at this time.
}
/**

View File

@ -238,9 +238,9 @@ public:
#define MODULE_PADS_LOCKED 0x08 ///< In autoplace: module waiting for autoplace
bool IsLocked() const
bool IsLocked() const override
{
return (m_ModuleStatus & MODULE_is_LOCKED) != 0;
return ( m_ModuleStatus & MODULE_is_LOCKED ) != 0;
}
/**
@ -248,7 +248,7 @@ public:
* sets the MODULE_is_LOCKED bit in the m_ModuleStatus
* @param isLocked When true means turn on locked status, else unlock
*/
void SetLocked( bool isLocked )
void SetLocked( bool isLocked ) override
{
if( isLocked )
m_ModuleStatus |= MODULE_is_LOCKED;

View File

@ -132,6 +132,9 @@ public:
// Virtual function
const EDA_RECT GetBoundingBox() const;
bool IsLocked() const override { return GetState( TRACK_LOCKED ); }
void SetLocked( bool aLocked ) override { return SetState( TRACK_LOCKED, aLocked ); }
/**
* Function GetBestInsertPoint
* searches the "best" insertion point within the track linked list.

View File

@ -399,9 +399,17 @@ TOOL_ACTION COMMON_ACTIONS::crossProbeSchToPcb( "pcbnew.EditorControl.crossProbS
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION COMMON_ACTIONS::toggleLockModule( "pcbnew.EditorControl.toggleLockModule",
TOOL_ACTION COMMON_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock",
AS_GLOBAL, 'L',
"", "" );
"Toggle lock", "" );
TOOL_ACTION COMMON_ACTIONS::lock( "pcbnew.EditorControl.lock",
AS_GLOBAL, 0,
_( "Lock" ), "" );
TOOL_ACTION COMMON_ACTIONS::unlock( "pcbnew.EditorControl.unlock",
AS_GLOBAL, 0,
_( "Unlock" ), "" );
TOOL_ACTION COMMON_ACTIONS::appendBoard( "pcbnew.EditorControl.appendBoard",
AS_GLOBAL, 0,

View File

@ -290,6 +290,11 @@ public:
static TOOL_ACTION panLeft;
static TOOL_ACTION panRight;
// Locking
static TOOL_ACTION toggleLock;
static TOOL_ACTION lock;
static TOOL_ACTION unlock;
// Miscellaneous
static TOOL_ACTION selectionTool;
static TOOL_ACTION pickerTool;
@ -301,7 +306,6 @@ public:
static TOOL_ACTION highlightNetCursor;
static TOOL_ACTION drillOrigin;
static TOOL_ACTION crossProbeSchToPcb;
static TOOL_ACTION toggleLockModule;
static TOOL_ACTION appendBoard;
static TOOL_ACTION showHelp;
static TOOL_ACTION toBeDone;

View File

@ -81,6 +81,19 @@ private:
};
class LOCK_CONTEXT_MENU : public CONTEXT_MENU
{
public:
LOCK_CONTEXT_MENU()
{
SetIcon( locked_xpm );
Add( COMMON_ACTIONS::lock );
Add( COMMON_ACTIONS::unlock );
Add( COMMON_ACTIONS::toggleLock );
}
};
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
TOOL_INTERACTIVE( "pcbnew.EditorControl" ), m_frame( NULL ), m_zoneMenu( NULL )
{
@ -94,6 +107,7 @@ PCB_EDITOR_CONTROL::~PCB_EDITOR_CONTROL()
{
delete m_placeOrigin;
delete m_zoneMenu;
delete m_lockMenu;
}
@ -120,6 +134,11 @@ bool PCB_EDITOR_CONTROL::Init()
m_zoneMenu->SetTool( this );
selTool->GetMenu().AddMenu( m_zoneMenu, _( "Zones" ), false,
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
m_lockMenu = new LOCK_CONTEXT_MENU;
m_lockMenu->SetTool( this );
selTool->GetMenu().AddMenu( m_lockMenu, _( "Locking" ), false,
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
}
return true;
@ -319,26 +338,61 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::ToggleLockModule( const TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::ToggleLockSelected( const TOOL_EVENT& aEvent )
{
return modifyLockSelected( TOGGLE );
}
int PCB_EDITOR_CONTROL::LockSelected( const TOOL_EVENT& aEvent )
{
return modifyLockSelected( ON );
}
int PCB_EDITOR_CONTROL::UnlockSelected( const TOOL_EVENT& aEvent )
{
return modifyLockSelected( OFF );
}
int PCB_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
bool clearSelection = selection.Empty();
if( clearSelection )
if( selection.Empty() )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
bool modified = false;
for( int i = 0; i < selection.Size(); ++i )
{
if( selection.Item<BOARD_ITEM>( i )->Type() == PCB_MODULE_T )
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
bool prevState = item->IsLocked();
switch( aMode )
{
MODULE* module = selection.Item<MODULE>( i );
module->SetLocked( !module->IsLocked() );
case ON:
item->SetLocked( true );
break;
case OFF:
item->SetLocked( false );
break;
case TOGGLE:
item->SetLocked( !prevState );
break;
}
// Check if we really modified an item
if( !modified && prevState != item->IsLocked() )
modified = true;
}
if( clearSelection )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
if( modified )
m_frame->OnModify();
return 0;
}
@ -780,7 +834,9 @@ void PCB_EDITOR_CONTROL::SetTransitions()
Go( &PCB_EDITOR_CONTROL::PlaceModule, COMMON_ACTIONS::placeModule.MakeEvent() );
// Other
Go( &PCB_EDITOR_CONTROL::ToggleLockModule, COMMON_ACTIONS::toggleLockModule.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ToggleLockSelected, COMMON_ACTIONS::toggleLock.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::LockSelected, COMMON_ACTIONS::lock.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::UnlockSelected, COMMON_ACTIONS::unlock.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::CrossProbePcbToSch, SELECTION_TOOL::SelectedEvent );
Go( &PCB_EDITOR_CONTROL::CrossProbeSchToPcb, COMMON_ACTIONS::crossProbeSchToPcb.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::DrillOrigin, COMMON_ACTIONS::drillOrigin.MakeEvent() );

View File

@ -33,6 +33,7 @@ namespace KIGFX {
class PCB_EDIT_FRAME;
class ZONE_CONTEXT_MENU;
class LOCK_CONTEXT_MENU;
/**
* Class PCB_EDITOR_CONTROL
@ -76,8 +77,14 @@ public:
*/
int PlaceModule( const TOOL_EVENT& aEvent );
///> (Un)locks module.
int ToggleLockModule( const TOOL_EVENT& aEvent );
///> Toggles 'lock' property for selected items.
int ToggleLockSelected( const TOOL_EVENT& aEvent );
///> Locks selected items.
int LockSelected( const TOOL_EVENT& aEvent );
///> Unlocks selected items.
int UnlockSelected( const TOOL_EVENT& aEvent );
///> Notifies eeschema about the selected item.
int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
@ -107,10 +114,16 @@ private:
///> Flag to ignore a single crossprobe message from eeschema.
bool m_probingSchToPcb;
///> How to modify a property for selected items.
enum MODIFY_MODE { ON, OFF, TOGGLE };
int modifyLockSelected( MODIFY_MODE aMode );
// How does line width change after one -/+ key press.
static const int WIDTH_STEP;
ZONE_CONTEXT_MENU* m_zoneMenu;
LOCK_CONTEXT_MENU* m_lockMenu;
};
#endif