diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 8d643b4a67..1d3283a276 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -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 ); diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 295cce8670..f7e0dd4c2a 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -399,7 +399,7 @@ public: virtual EDA_COLOR_T GetGridColor() const; ///> @copydoc PCB_BASE_FRAME::SetActiveLayer() - void SetActiveLayer( LAYER_NUM aLayer ); + void SetActiveLayer( LAYER_ID aLayer ); ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() virtual void UseGalCanvas( bool aEnable ); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 49f24e749d..1649b24b74 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -271,6 +271,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : drawPanel->SetEventDispatcher( m_toolDispatcher ); m_toolManager->RegisterTool( new SELECTION_TOOL ); + m_toolManager->GetTool()->EditModules( true ); m_toolManager->RegisterTool( new EDIT_TOOL ); m_toolManager->RegisterTool( new DRAWING_TOOL ); m_toolManager->RegisterTool( new POINT_EDITOR ); diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 0953e7f517..591bfb9e3e 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -54,7 +54,7 @@ SELECTION_TOOL::SELECTION_TOOL() : SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ), DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ), 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_selection.group = new KIGFX::VIEW_GROUP; @@ -189,8 +189,12 @@ bool SELECTION_TOOL::SelectSingle( const VECTOR2I& aWhere, bool aAllowDisambigua GENERAL_COLLECTOR collector; const KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, PCB_LINE_T, EOT }; // preferred types - collector.Collect( getModel(), GENERAL_COLLECTOR::AllBoardItems, - wxPoint( aWhere.x, aWhere.y ), guide ); + if( m_editModules ) + collector.Collect( getModel(), GENERAL_COLLECTOR::ModulesAndTheirItems, + wxPoint( aWhere.x, aWhere.y ), guide ); + else + collector.Collect( getModel(), GENERAL_COLLECTOR::AllBoardItems, + wxPoint( aWhere.x, aWhere.y ), guide ); switch( collector.GetCount() ) { @@ -532,23 +536,25 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const case PCB_MODULE_T: 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 ) ) - return true; + return !m_editModules; return false; break; case PCB_MODULE_TEXT_T: - if( m_multiple ) + if( m_multiple && !m_editModules ) return false; break; // These are not selectable case PCB_MODULE_EDGE_T: case PCB_PAD_T: + return m_editModules; + case NOT_USED: case TYPE_NOT_INIT: return false; diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 2f8a58fcf1..642b2ee358 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -139,6 +139,17 @@ public: */ 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. const TOOL_EVENT SelectedEvent; @@ -260,6 +271,9 @@ private: /// Right click popup menu CONTEXT_MENU m_menu; + + /// Edit module mode flag + bool m_editModules; }; #endif