Commit 7ade7db0 authored by Maciej Suminski's avatar Maciej Suminski

SELECTION_TOOL got a new mode to edit MODULEs.

parent d98a5c4e
...@@ -916,7 +916,7 @@ EDA_COLOR_T FOOTPRINT_EDIT_FRAME::GetGridColor() const ...@@ -916,7 +916,7 @@ EDA_COLOR_T FOOTPRINT_EDIT_FRAME::GetGridColor() const
} }
void FOOTPRINT_EDIT_FRAME::SetActiveLayer( LAYER_NUM aLayer ) void FOOTPRINT_EDIT_FRAME::SetActiveLayer( LAYER_ID aLayer )
{ {
PCB_BASE_FRAME::SetActiveLayer( aLayer ); PCB_BASE_FRAME::SetActiveLayer( aLayer );
......
...@@ -399,7 +399,7 @@ public: ...@@ -399,7 +399,7 @@ public:
virtual EDA_COLOR_T GetGridColor() const; virtual EDA_COLOR_T GetGridColor() const;
///> @copydoc PCB_BASE_FRAME::SetActiveLayer() ///> @copydoc PCB_BASE_FRAME::SetActiveLayer()
void SetActiveLayer( LAYER_NUM aLayer ); void SetActiveLayer( LAYER_ID aLayer );
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
virtual void UseGalCanvas( bool aEnable ); virtual void UseGalCanvas( bool aEnable );
......
...@@ -271,6 +271,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : ...@@ -271,6 +271,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
drawPanel->SetEventDispatcher( m_toolDispatcher ); drawPanel->SetEventDispatcher( m_toolDispatcher );
m_toolManager->RegisterTool( new SELECTION_TOOL ); m_toolManager->RegisterTool( new SELECTION_TOOL );
m_toolManager->GetTool<SELECTION_TOOL>()->EditModules( true );
m_toolManager->RegisterTool( new EDIT_TOOL ); m_toolManager->RegisterTool( new EDIT_TOOL );
m_toolManager->RegisterTool( new DRAWING_TOOL ); m_toolManager->RegisterTool( new DRAWING_TOOL );
m_toolManager->RegisterTool( new POINT_EDITOR ); m_toolManager->RegisterTool( new POINT_EDITOR );
......
...@@ -54,7 +54,7 @@ SELECTION_TOOL::SELECTION_TOOL() : ...@@ -54,7 +54,7 @@ SELECTION_TOOL::SELECTION_TOOL() :
SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ), SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ),
DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ), DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ),
ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" ), ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" ),
m_additive( false ), m_multiple( false ) m_additive( false ), m_multiple( false ), m_editModules( false )
{ {
m_selArea = new SELECTION_AREA; m_selArea = new SELECTION_AREA;
m_selection.group = new KIGFX::VIEW_GROUP; m_selection.group = new KIGFX::VIEW_GROUP;
...@@ -189,6 +189,10 @@ bool SELECTION_TOOL::SelectSingle( const VECTOR2I& aWhere, bool aAllowDisambigua ...@@ -189,6 +189,10 @@ bool SELECTION_TOOL::SelectSingle( const VECTOR2I& aWhere, bool aAllowDisambigua
GENERAL_COLLECTOR collector; GENERAL_COLLECTOR collector;
const KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, PCB_LINE_T, EOT }; // preferred types const KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, PCB_LINE_T, EOT }; // preferred types
if( m_editModules )
collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::ModulesAndTheirItems,
wxPoint( aWhere.x, aWhere.y ), guide );
else
collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::AllBoardItems, collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::AllBoardItems,
wxPoint( aWhere.x, aWhere.y ), guide ); wxPoint( aWhere.x, aWhere.y ), guide );
...@@ -532,23 +536,25 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const ...@@ -532,23 +536,25 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
case PCB_MODULE_T: case PCB_MODULE_T:
if( aItem->IsOnLayer( F_Cu ) && board->IsElementVisible( MOD_FR_VISIBLE ) ) if( aItem->IsOnLayer( F_Cu ) && board->IsElementVisible( MOD_FR_VISIBLE ) )
return true; return !m_editModules;
if( aItem->IsOnLayer( B_Cu ) && board->IsElementVisible( MOD_BK_VISIBLE ) ) if( aItem->IsOnLayer( B_Cu ) && board->IsElementVisible( MOD_BK_VISIBLE ) )
return true; return !m_editModules;
return false; return false;
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
if( m_multiple ) if( m_multiple && !m_editModules )
return false; return false;
break; break;
// These are not selectable // These are not selectable
case PCB_MODULE_EDGE_T: case PCB_MODULE_EDGE_T:
case PCB_PAD_T: case PCB_PAD_T:
return m_editModules;
case NOT_USED: case NOT_USED:
case TYPE_NOT_INIT: case TYPE_NOT_INIT:
return false; return false;
......
...@@ -139,6 +139,17 @@ public: ...@@ -139,6 +139,17 @@ public:
*/ */
void AddMenuItem( const TOOL_ACTION& aAction ); void AddMenuItem( const TOOL_ACTION& aAction );
/**
* Function EditModules()
* Toggles edit module mode. When enabled, one may select parts of modules individually
* (graphics, pads, etc.), so they can be modified.
* @param aEnabled decides if the mode should be enabled.
*/
void EditModules( bool aEnabled )
{
m_editModules = aEnabled;
}
///> Event sent after an item is selected. ///> Event sent after an item is selected.
const TOOL_EVENT SelectedEvent; const TOOL_EVENT SelectedEvent;
...@@ -260,6 +271,9 @@ private: ...@@ -260,6 +271,9 @@ private:
/// Right click popup menu /// Right click popup menu
CONTEXT_MENU m_menu; CONTEXT_MENU m_menu;
/// Edit module mode flag
bool m_editModules;
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment