Loading pcbnew/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,7 @@ set( PCBNEW_CLASS_SRCS tools/edit_tool.cpp tools/pcbnew_control.cpp tools/pcb_editor_control.cpp tools/module_tools.cpp tools/placement_tool.cpp tools/common_actions.cpp ) Loading pcbnew/moduleframe.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ #include "tools/drawing_tool.h" #include "tools/point_editor.h" #include "tools/pcbnew_control.h" #include "tools/module_tools.h" #include "tools/placement_tool.h" #include "tools/common_actions.h" Loading Loading @@ -280,6 +281,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_toolManager->RegisterTool( new DRAWING_TOOL ); m_toolManager->RegisterTool( new POINT_EDITOR ); m_toolManager->RegisterTool( new PCBNEW_CONTROL ); m_toolManager->RegisterTool( new MODULE_TOOLS ); m_toolManager->RegisterTool( new PLACEMENT_TOOL ); m_toolManager->GetTool<SELECTION_TOOL>()->EditModules( true ); Loading pcbnew/tools/common_actions.cpp +14 −12 Original line number Diff line number Diff line Loading @@ -59,14 +59,6 @@ TOOL_ACTION COMMON_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", AS_GLOBAL, 'E', "Properties...", "Displays properties window" ); TOOL_ACTION COMMON_ACTIONS::copyItems( "pcbnew.InteractiveEdit.copyItems", AS_GLOBAL, MD_CTRL + int( 'C' ), "Copy items", "Copy items", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.InteractiveEdit.pasteItems", AS_GLOBAL, MD_CTRL + int( 'V' ), "Paste items", "Paste items", AF_ACTIVATE ); // Drawing tool actions TOOL_ACTION COMMON_ACTIONS::drawLine( "pcbnew.InteractiveDrawing.line", Loading Loading @@ -105,10 +97,6 @@ TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.InteractiveDrawing.placeModule" AS_GLOBAL, 'O', "Add modules", "Add modules", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.InteractiveDrawing.placePad", AS_GLOBAL, 0, "Add pads", "Add pads", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::placeDXF( "pcbnew.InteractiveDrawing.placeDXF", AS_GLOBAL, 0, "", "", AF_ACTIVATE ); Loading Loading @@ -276,6 +264,20 @@ TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaS "", "" ); // Module editor tools TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad", AS_GLOBAL, 0, "Add pads", "Add pads", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::copyItems( "pcbnew.ModuleEditor.copyItems", AS_GLOBAL, MD_CTRL + int( 'C' ), "Copy items", "Copy items", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.ModuleEditor.pasteItems", AS_GLOBAL, MD_CTRL + int( 'V' ), "Paste items", "Paste items", AF_ACTIVATE ); // Miscellaneous TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords", AS_GLOBAL, ' ', Loading pcbnew/tools/common_actions.h +12 −8 Original line number Diff line number Diff line Loading @@ -62,11 +62,6 @@ public: /// Deleting a BOARD_ITEM static TOOL_ACTION remove; /// Copying pad to clipboard static TOOL_ACTION copyItems; /// Pasting a pad from clipboard static TOOL_ACTION pasteItems; // Drawing Tool /// Activation of the drawing tool (line) Loading Loading @@ -96,9 +91,6 @@ public: /// Activation of the drawing tool (placing a MODULE) static TOOL_ACTION placeModule; /// Activation of the drawing tool (placing a PAD) static TOOL_ACTION placePad; /// Activation of the drawing tool (placing a drawing from DXF file) static TOOL_ACTION placeDXF; Loading Loading @@ -180,6 +172,18 @@ public: static TOOL_ACTION trackViaSizeChanged; // notification // Module editor tools /// Activation of the drawing tool (placing a PAD) static TOOL_ACTION placePad; /// Copying module items to clipboard static TOOL_ACTION copyItems; /// Pasting module items from clipboard static TOOL_ACTION pasteItems; // Miscellaneous static TOOL_ACTION resetCoords; static TOOL_ACTION switchUnits; Loading pcbnew/tools/drawing_tool.cpp +0 −152 Original line number Diff line number Diff line Loading @@ -615,110 +615,6 @@ int DRAWING_TOOL::PlaceModule( TOOL_EVENT& aEvent ) } int DRAWING_TOOL::PlacePad( TOOL_EVENT& aEvent ) { assert( m_editModules ); m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); MODULE* module = m_board->m_Modules; assert( module ); D_PAD* pad = new D_PAD( module ); m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad VECTOR2I cursorPos = m_controls->GetCursorPosition(); pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); // Add a VIEW_GROUP that serves as a preview for the new item KIGFX::VIEW_GROUP preview( m_view ); preview.Add( pad ); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); Activate(); // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { cursorPos = m_controls->GetCursorPosition(); if( evt->IsMotion() ) { pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); preview.ViewUpdate(); } else if( evt->Category() == TC_COMMAND ) { if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { pad->Rotate( pad->GetPosition(), m_frame->GetRotationAngle() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) { pad->Flip( pad->GetPosition() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } else if( evt->IsCancel() || evt->IsActivate() ) { preview.Clear(); delete pad; break; } } else if( evt->IsClick( BUT_LEFT ) ) { m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view module->SetLastEditTime(); module->Pads().PushBack( pad ); pad->SetNetCode( NETINFO_LIST::UNCONNECTED ); // Set the relative pad position // ( pad position for module orient, 0, and relative to the module position) pad->SetLocalCoord(); /* NPTH pads take empty pad number (since they can't be connected), * other pads get incremented from the last one edited */ wxString padName; if( pad->GetAttribute() != PAD_HOLE_NOT_PLATED ) padName = getNextPadName(); pad->SetPadName( padName ); // Handle the view aspect preview.Remove( pad ); m_view->Add( pad ); // Start placing next pad pad = new D_PAD( module ); m_frame->Import_Pad_Settings( pad, false ); preview.Add( pad ); } } m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_view->Remove( &preview ); setTransitions(); m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); return 0; } int DRAWING_TOOL::PlaceDXF( TOOL_EVENT& aEvent ) { DIALOG_DXF_IMPORT dlg( m_frame ); Loading Loading @@ -1735,53 +1631,6 @@ void DRAWING_TOOL::make45DegLine( DRAWSEGMENT* aSegment, DRAWSEGMENT* aHelper ) } bool isNotDigit( char aChar ) { return ( aChar < '0' || aChar > '9' ); } wxString DRAWING_TOOL::getNextPadName() const { std::set<int> usedNumbers; // Find the first, not used pad number for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) { for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) { wxString padName = pad->GetPadName(); int padNumber = 0; int base = 1; // Trim and extract the trailing numeric part while( padName.Len() && padName.Last() >= '0' && padName.Last() <= '9' ) { padNumber += ( padName.Last() - '0' ) * base; padName.RemoveLast(); base *= 10; } usedNumbers.insert( padNumber ); } } int candidate = *usedNumbers.begin(); // Look for a gap in pad numbering for( std::set<int>::iterator it = usedNumbers.begin(), itEnd = usedNumbers.end(); it != itEnd; ++it ) { if( *it - candidate > 1 ) break; candidate = *it; } return wxString::Format( wxT( "%i" ), ++candidate ); } void DRAWING_TOOL::setTransitions() { Go( &DRAWING_TOOL::DrawLine, COMMON_ACTIONS::drawLine.MakeEvent() ); Loading @@ -1793,7 +1642,6 @@ void DRAWING_TOOL::setTransitions() Go( &DRAWING_TOOL::PlaceText, COMMON_ACTIONS::placeText.MakeEvent() ); Go( &DRAWING_TOOL::PlaceTarget, COMMON_ACTIONS::placeTarget.MakeEvent() ); Go( &DRAWING_TOOL::PlaceModule, COMMON_ACTIONS::placeModule.MakeEvent() ); Go( &DRAWING_TOOL::PlacePad, COMMON_ACTIONS::placePad.MakeEvent() ); Go( &DRAWING_TOOL::PlaceDXF, COMMON_ACTIONS::placeDXF.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, COMMON_ACTIONS::setAnchor.MakeEvent() ); } Loading
pcbnew/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,7 @@ set( PCBNEW_CLASS_SRCS tools/edit_tool.cpp tools/pcbnew_control.cpp tools/pcb_editor_control.cpp tools/module_tools.cpp tools/placement_tool.cpp tools/common_actions.cpp ) Loading
pcbnew/moduleframe.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ #include "tools/drawing_tool.h" #include "tools/point_editor.h" #include "tools/pcbnew_control.h" #include "tools/module_tools.h" #include "tools/placement_tool.h" #include "tools/common_actions.h" Loading Loading @@ -280,6 +281,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_toolManager->RegisterTool( new DRAWING_TOOL ); m_toolManager->RegisterTool( new POINT_EDITOR ); m_toolManager->RegisterTool( new PCBNEW_CONTROL ); m_toolManager->RegisterTool( new MODULE_TOOLS ); m_toolManager->RegisterTool( new PLACEMENT_TOOL ); m_toolManager->GetTool<SELECTION_TOOL>()->EditModules( true ); Loading
pcbnew/tools/common_actions.cpp +14 −12 Original line number Diff line number Diff line Loading @@ -59,14 +59,6 @@ TOOL_ACTION COMMON_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", AS_GLOBAL, 'E', "Properties...", "Displays properties window" ); TOOL_ACTION COMMON_ACTIONS::copyItems( "pcbnew.InteractiveEdit.copyItems", AS_GLOBAL, MD_CTRL + int( 'C' ), "Copy items", "Copy items", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.InteractiveEdit.pasteItems", AS_GLOBAL, MD_CTRL + int( 'V' ), "Paste items", "Paste items", AF_ACTIVATE ); // Drawing tool actions TOOL_ACTION COMMON_ACTIONS::drawLine( "pcbnew.InteractiveDrawing.line", Loading Loading @@ -105,10 +97,6 @@ TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.InteractiveDrawing.placeModule" AS_GLOBAL, 'O', "Add modules", "Add modules", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.InteractiveDrawing.placePad", AS_GLOBAL, 0, "Add pads", "Add pads", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::placeDXF( "pcbnew.InteractiveDrawing.placeDXF", AS_GLOBAL, 0, "", "", AF_ACTIVATE ); Loading Loading @@ -276,6 +264,20 @@ TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaS "", "" ); // Module editor tools TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad", AS_GLOBAL, 0, "Add pads", "Add pads", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::copyItems( "pcbnew.ModuleEditor.copyItems", AS_GLOBAL, MD_CTRL + int( 'C' ), "Copy items", "Copy items", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.ModuleEditor.pasteItems", AS_GLOBAL, MD_CTRL + int( 'V' ), "Paste items", "Paste items", AF_ACTIVATE ); // Miscellaneous TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords", AS_GLOBAL, ' ', Loading
pcbnew/tools/common_actions.h +12 −8 Original line number Diff line number Diff line Loading @@ -62,11 +62,6 @@ public: /// Deleting a BOARD_ITEM static TOOL_ACTION remove; /// Copying pad to clipboard static TOOL_ACTION copyItems; /// Pasting a pad from clipboard static TOOL_ACTION pasteItems; // Drawing Tool /// Activation of the drawing tool (line) Loading Loading @@ -96,9 +91,6 @@ public: /// Activation of the drawing tool (placing a MODULE) static TOOL_ACTION placeModule; /// Activation of the drawing tool (placing a PAD) static TOOL_ACTION placePad; /// Activation of the drawing tool (placing a drawing from DXF file) static TOOL_ACTION placeDXF; Loading Loading @@ -180,6 +172,18 @@ public: static TOOL_ACTION trackViaSizeChanged; // notification // Module editor tools /// Activation of the drawing tool (placing a PAD) static TOOL_ACTION placePad; /// Copying module items to clipboard static TOOL_ACTION copyItems; /// Pasting module items from clipboard static TOOL_ACTION pasteItems; // Miscellaneous static TOOL_ACTION resetCoords; static TOOL_ACTION switchUnits; Loading
pcbnew/tools/drawing_tool.cpp +0 −152 Original line number Diff line number Diff line Loading @@ -615,110 +615,6 @@ int DRAWING_TOOL::PlaceModule( TOOL_EVENT& aEvent ) } int DRAWING_TOOL::PlacePad( TOOL_EVENT& aEvent ) { assert( m_editModules ); m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); MODULE* module = m_board->m_Modules; assert( module ); D_PAD* pad = new D_PAD( module ); m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad VECTOR2I cursorPos = m_controls->GetCursorPosition(); pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); // Add a VIEW_GROUP that serves as a preview for the new item KIGFX::VIEW_GROUP preview( m_view ); preview.Add( pad ); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); Activate(); // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { cursorPos = m_controls->GetCursorPosition(); if( evt->IsMotion() ) { pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); preview.ViewUpdate(); } else if( evt->Category() == TC_COMMAND ) { if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { pad->Rotate( pad->GetPosition(), m_frame->GetRotationAngle() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) { pad->Flip( pad->GetPosition() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } else if( evt->IsCancel() || evt->IsActivate() ) { preview.Clear(); delete pad; break; } } else if( evt->IsClick( BUT_LEFT ) ) { m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view module->SetLastEditTime(); module->Pads().PushBack( pad ); pad->SetNetCode( NETINFO_LIST::UNCONNECTED ); // Set the relative pad position // ( pad position for module orient, 0, and relative to the module position) pad->SetLocalCoord(); /* NPTH pads take empty pad number (since they can't be connected), * other pads get incremented from the last one edited */ wxString padName; if( pad->GetAttribute() != PAD_HOLE_NOT_PLATED ) padName = getNextPadName(); pad->SetPadName( padName ); // Handle the view aspect preview.Remove( pad ); m_view->Add( pad ); // Start placing next pad pad = new D_PAD( module ); m_frame->Import_Pad_Settings( pad, false ); preview.Add( pad ); } } m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_view->Remove( &preview ); setTransitions(); m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); return 0; } int DRAWING_TOOL::PlaceDXF( TOOL_EVENT& aEvent ) { DIALOG_DXF_IMPORT dlg( m_frame ); Loading Loading @@ -1735,53 +1631,6 @@ void DRAWING_TOOL::make45DegLine( DRAWSEGMENT* aSegment, DRAWSEGMENT* aHelper ) } bool isNotDigit( char aChar ) { return ( aChar < '0' || aChar > '9' ); } wxString DRAWING_TOOL::getNextPadName() const { std::set<int> usedNumbers; // Find the first, not used pad number for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) { for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) { wxString padName = pad->GetPadName(); int padNumber = 0; int base = 1; // Trim and extract the trailing numeric part while( padName.Len() && padName.Last() >= '0' && padName.Last() <= '9' ) { padNumber += ( padName.Last() - '0' ) * base; padName.RemoveLast(); base *= 10; } usedNumbers.insert( padNumber ); } } int candidate = *usedNumbers.begin(); // Look for a gap in pad numbering for( std::set<int>::iterator it = usedNumbers.begin(), itEnd = usedNumbers.end(); it != itEnd; ++it ) { if( *it - candidate > 1 ) break; candidate = *it; } return wxString::Format( wxT( "%i" ), ++candidate ); } void DRAWING_TOOL::setTransitions() { Go( &DRAWING_TOOL::DrawLine, COMMON_ACTIONS::drawLine.MakeEvent() ); Loading @@ -1793,7 +1642,6 @@ void DRAWING_TOOL::setTransitions() Go( &DRAWING_TOOL::PlaceText, COMMON_ACTIONS::placeText.MakeEvent() ); Go( &DRAWING_TOOL::PlaceTarget, COMMON_ACTIONS::placeTarget.MakeEvent() ); Go( &DRAWING_TOOL::PlaceModule, COMMON_ACTIONS::placeModule.MakeEvent() ); Go( &DRAWING_TOOL::PlacePad, COMMON_ACTIONS::placePad.MakeEvent() ); Go( &DRAWING_TOOL::PlaceDXF, COMMON_ACTIONS::placeDXF.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, COMMON_ACTIONS::setAnchor.MakeEvent() ); }