pcbnew: rename PLACEMENT_TOOL to ALIGN_DISTRIBUTE_TOOL, some fixes in the connectivity algo
This commit is contained in:
parent
c4c329e393
commit
bfdd1191ab
|
@ -139,6 +139,7 @@ public:
|
||||||
const DLIST<BOARD_ITEM>& GraphicalItems() const { return m_Drawings; }
|
const DLIST<BOARD_ITEM>& GraphicalItems() const { return m_Drawings; }
|
||||||
|
|
||||||
DLIST_ITERATOR_WRAPPER<D_PAD> PadsIter() { return DLIST_ITERATOR_WRAPPER<D_PAD>(m_Pads); }
|
DLIST_ITERATOR_WRAPPER<D_PAD> PadsIter() { return DLIST_ITERATOR_WRAPPER<D_PAD>(m_Pads); }
|
||||||
|
DLIST_ITERATOR_WRAPPER<BOARD_ITEM> GraphicalItemsIter() { return DLIST_ITERATOR_WRAPPER<BOARD_ITEM>(m_Drawings); }
|
||||||
|
|
||||||
std::list<S3D_INFO>& Models() { return m_3D_Drawings; }
|
std::list<S3D_INFO>& Models() { return m_3D_Drawings; }
|
||||||
const std::list<S3D_INFO>& Models() const { return m_3D_Drawings; }
|
const std::list<S3D_INFO>& Models() const { return m_3D_Drawings; }
|
||||||
|
|
|
@ -138,6 +138,8 @@ void CONNECTIVITY_DATA::addRatsnestCluster( std::shared_ptr<CN_CLUSTER> aCluster
|
||||||
|
|
||||||
void CONNECTIVITY_DATA::RecalculateRatsnest()
|
void CONNECTIVITY_DATA::RecalculateRatsnest()
|
||||||
{
|
{
|
||||||
|
m_connAlgo->PropagateNets();
|
||||||
|
|
||||||
int lastNet = m_connAlgo->NetCount();
|
int lastNet = m_connAlgo->NetCount();
|
||||||
|
|
||||||
if( lastNet >= (int) m_nets.size() )
|
if( lastNet >= (int) m_nets.size() )
|
||||||
|
@ -451,8 +453,18 @@ unsigned int CONNECTIVITY_DATA::GetNodeCount( int aNet ) const
|
||||||
|
|
||||||
unsigned int CONNECTIVITY_DATA::GetPadCount( int aNet ) const
|
unsigned int CONNECTIVITY_DATA::GetPadCount( int aNet ) const
|
||||||
{
|
{
|
||||||
return 0;
|
int n = 0;
|
||||||
assert( false );
|
|
||||||
|
for ( auto pad : m_connAlgo->PadList() )
|
||||||
|
{
|
||||||
|
auto dpad = static_cast<D_PAD*>( pad->Parent() );
|
||||||
|
if ( aNet < 0 || aNet == dpad->GetNetCode() )
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -943,6 +943,8 @@ public:
|
||||||
const CLUSTERS& GetClusters();
|
const CLUSTERS& GetClusters();
|
||||||
int GetUnconnectedCount();
|
int GetUnconnectedCount();
|
||||||
|
|
||||||
|
CN_PAD_LIST& PadList() { return m_padList; }
|
||||||
|
|
||||||
void ForEachAnchor( std::function<void(CN_ANCHOR_PTR)> aFunc );
|
void ForEachAnchor( std::function<void(CN_ANCHOR_PTR)> aFunc );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -978,7 +978,7 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
|
||||||
m_toolManager->RegisterTool( new POINT_EDITOR );
|
m_toolManager->RegisterTool( new POINT_EDITOR );
|
||||||
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
||||||
m_toolManager->RegisterTool( new MODULE_EDITOR_TOOLS );
|
m_toolManager->RegisterTool( new MODULE_EDITOR_TOOLS );
|
||||||
m_toolManager->RegisterTool( new PLACEMENT_TOOL );
|
m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
|
||||||
m_toolManager->RegisterTool( new PICKER_TOOL );
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
||||||
|
|
||||||
m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
|
m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
|
||||||
|
|
|
@ -80,8 +80,7 @@ TOOL_ACTION PCB_ACTIONS::moduleTextOutlines( "pcbnew.ModuleEditor.textOutlines",
|
||||||
|
|
||||||
|
|
||||||
MODULE_EDITOR_TOOLS::MODULE_EDITOR_TOOLS() :
|
MODULE_EDITOR_TOOLS::MODULE_EDITOR_TOOLS() :
|
||||||
TOOL_INTERACTIVE( "pcbnew.ModuleEditor" ), m_view( NULL ), m_controls( NULL ),
|
PCB_TOOL( "pcbnew.ModuleEditor" )
|
||||||
m_board( NULL ), m_frame( NULL )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,46 +92,41 @@ MODULE_EDITOR_TOOLS::~MODULE_EDITOR_TOOLS()
|
||||||
|
|
||||||
void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason )
|
void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason )
|
||||||
{
|
{
|
||||||
// Init variables used by every drawing tool
|
|
||||||
m_view = getView();
|
|
||||||
m_controls = getViewControls();
|
|
||||||
m_board = getModel<BOARD>();
|
|
||||||
m_frame = getEditFrame<PCB_EDIT_FRAME>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
|
frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
|
||||||
|
|
||||||
assert( m_board->m_Modules );
|
assert( board()->m_Modules );
|
||||||
|
|
||||||
D_PAD* pad = new D_PAD( m_board->m_Modules );
|
D_PAD* pad = new D_PAD( board()->m_Modules );
|
||||||
m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad
|
frame()->Import_Pad_Settings( pad, false ); // use the global settings for pad
|
||||||
|
|
||||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
||||||
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||||
|
|
||||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
// Add a VIEW_GROUP that serves as a preview for the new item
|
||||||
KIGFX::VIEW_GROUP preview( m_view );
|
KIGFX::VIEW_GROUP preview( view() );
|
||||||
preview.Add( pad );
|
preview.Add( pad );
|
||||||
m_view->Add( &preview );
|
view()->Add( &preview );
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_controls->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
m_controls->SetSnapping( true );
|
getViewControls()->SetSnapping( true );
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
cursorPos = m_controls->GetCursorPosition();
|
cursorPos = getViewControls()->GetCursorPosition();
|
||||||
|
|
||||||
if( evt->IsMotion() )
|
if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||||
m_view->Update( &preview );
|
view()->Update( &preview );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->Category() == TC_COMMAND )
|
else if( evt->Category() == TC_COMMAND )
|
||||||
|
@ -140,14 +134,14 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
||||||
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
|
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
|
||||||
{
|
{
|
||||||
const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
|
const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
|
||||||
*m_frame, *evt );
|
*frame(), *evt );
|
||||||
pad->Rotate( pad->GetPosition(), rotationAngle );
|
pad->Rotate( pad->GetPosition(), rotationAngle );
|
||||||
m_view->Update( &preview );
|
view()->Update( &preview );
|
||||||
}
|
}
|
||||||
else if( evt->IsAction( &PCB_ACTIONS::flip ) )
|
else if( evt->IsAction( &PCB_ACTIONS::flip ) )
|
||||||
{
|
{
|
||||||
pad->Flip( pad->GetPosition() );
|
pad->Flip( pad->GetPosition() );
|
||||||
m_view->Update( &preview );
|
view()->Update( &preview );
|
||||||
}
|
}
|
||||||
else if( evt->IsCancel() || evt->IsActivate() )
|
else if( evt->IsCancel() || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
|
@ -159,10 +153,10 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
BOARD_COMMIT commit( m_frame );
|
BOARD_COMMIT commit( frame() );
|
||||||
commit.Add( pad );
|
commit.Add( pad );
|
||||||
|
|
||||||
m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
board()->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
||||||
|
|
||||||
// Take the next available pad number
|
// Take the next available pad number
|
||||||
pad->IncrementPadName( true, true );
|
pad->IncrementPadName( true, true );
|
||||||
|
@ -172,15 +166,15 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
||||||
commit.Push( _( "Add a pad" ) );
|
commit.Push( _( "Add a pad" ) );
|
||||||
|
|
||||||
// Start placing next pad
|
// Start placing next pad
|
||||||
pad = new D_PAD( m_board->m_Modules );
|
pad = new D_PAD( board()->m_Modules );
|
||||||
m_frame->Import_Pad_Settings( pad, false );
|
frame()->Import_Pad_Settings( pad, false );
|
||||||
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||||
preview.Add( pad );
|
preview.Add( pad );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_view->Remove( &preview );
|
view()->Remove( &preview );
|
||||||
m_frame->SetNoToolSelected();
|
frame()->SetNoToolSelected();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +182,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( !m_board->m_Modules || !m_board->m_Modules->Pads() )
|
if( !board()->m_Modules || !board()->m_Modules->Pads() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
@ -196,14 +190,14 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
GENERAL_COLLECTOR collector;
|
GENERAL_COLLECTOR collector;
|
||||||
const KICAD_T types[] = { PCB_PAD_T, EOT };
|
const KICAD_T types[] = { PCB_PAD_T, EOT };
|
||||||
|
|
||||||
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
GENERAL_COLLECTORS_GUIDE guide = frame()->GetCollectorsGuide();
|
||||||
guide.SetIgnoreMTextsMarkedNoShow( true );
|
guide.SetIgnoreMTextsMarkedNoShow( true );
|
||||||
guide.SetIgnoreMTextsOnBack( true );
|
guide.SetIgnoreMTextsOnBack( true );
|
||||||
guide.SetIgnoreMTextsOnFront( true );
|
guide.SetIgnoreMTextsOnFront( true );
|
||||||
guide.SetIgnoreModulesVals( true );
|
guide.SetIgnoreModulesVals( true );
|
||||||
guide.SetIgnoreModulesRefs( true );
|
guide.SetIgnoreModulesRefs( true );
|
||||||
|
|
||||||
DIALOG_ENUM_PADS settingsDlg( m_frame );
|
DIALOG_ENUM_PADS settingsDlg( frame() );
|
||||||
|
|
||||||
if( settingsDlg.ShowModal() == wxID_CANCEL )
|
if( settingsDlg.ShowModal() == wxID_CANCEL )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -211,15 +205,16 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
int padNumber = settingsDlg.GetStartNumber();
|
int padNumber = settingsDlg.GetStartNumber();
|
||||||
wxString padPrefix = settingsDlg.GetPrefix();
|
wxString padPrefix = settingsDlg.GetPrefix();
|
||||||
|
|
||||||
m_frame->DisplayToolMsg( _( "Hold left mouse button and move cursor over pads to enumerate them" ) );
|
frame()->DisplayToolMsg( _(
|
||||||
|
"Hold left mouse button and move cursor over pads to enumerate them" ) );
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_controls->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
KIGFX::VIEW* view = m_toolMgr->GetView();
|
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||||
VECTOR2I oldCursorPos = m_controls->GetCursorPosition();
|
VECTOR2I oldCursorPos = getViewControls()->GetCursorPosition();
|
||||||
std::list<D_PAD*> selectedPads;
|
std::list<D_PAD*> selectedPads;
|
||||||
BOARD_COMMIT commit( m_frame );
|
BOARD_COMMIT commit( frame() );
|
||||||
std::map<wxString, wxString> oldNames;
|
std::map<wxString, wxString> oldNames;
|
||||||
|
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
|
@ -227,13 +222,13 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
selectedPads.clear();
|
selectedPads.clear();
|
||||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
oldCursorPos = m_controls->GetCursorPosition();
|
oldCursorPos = getViewControls()->GetCursorPosition();
|
||||||
collector.Empty();
|
collector.Empty();
|
||||||
collector.Collect( m_board, types, wxPoint( cursorPos.x, cursorPos.y ), guide );
|
collector.Collect( board(), types, wxPoint( cursorPos.x, cursorPos.y ), guide );
|
||||||
|
|
||||||
for( int i = 0; i < collector.GetCount(); ++i )
|
for( int i = 0; i < collector.GetCount(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -253,7 +248,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
collector.Empty();
|
collector.Empty();
|
||||||
for( int j = 0; j < segments; ++j ) {
|
for( int j = 0; j < segments; ++j ) {
|
||||||
collector.Collect( m_board, types,
|
collector.Collect( board(), types,
|
||||||
wxPoint( oldCursorPos.x, oldCursorPos.y ) + j * LINE_STEP,
|
wxPoint( oldCursorPos.x, oldCursorPos.y ) + j * LINE_STEP,
|
||||||
guide );
|
guide );
|
||||||
|
|
||||||
|
@ -316,13 +311,13 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( D_PAD* p = m_board->m_Modules->Pads(); p; p = p->Next() )
|
for( D_PAD* p = board()->m_Modules->Pads(); p; p = p->Next() )
|
||||||
{
|
{
|
||||||
p->ClearSelected();
|
p->ClearSelected();
|
||||||
view->Update( p );
|
view->Update( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->DisplayToolMsg( wxEmptyString );
|
frame()->DisplayToolMsg( wxEmptyString );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -334,20 +329,20 @@ int MODULE_EDITOR_TOOLS::CopyItems( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
m_controls->SetSnapping( true );
|
getViewControls()->SetSnapping( true );
|
||||||
m_controls->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
m_controls->SetAutoPan( true );
|
getViewControls()->SetAutoPan( true );
|
||||||
|
|
||||||
m_frame->DisplayToolMsg( _( "Select reference point" ) );
|
frame()->DisplayToolMsg( _( "Select reference point" ) );
|
||||||
|
|
||||||
bool cancelled = false;
|
bool cancelled = false;
|
||||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
||||||
|
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
if( evt->IsMotion() )
|
if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
cursorPos = m_controls->GetCursorPosition();
|
cursorPos = getViewControls()->GetCursorPosition();
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
@ -365,7 +360,7 @@ int MODULE_EDITOR_TOOLS::CopyItems( const TOOL_EVENT& aEvent )
|
||||||
PCB_IO io( CTL_FOR_CLIPBOARD );
|
PCB_IO io( CTL_FOR_CLIPBOARD );
|
||||||
|
|
||||||
// Create a temporary module that contains selected items to ease serialization
|
// Create a temporary module that contains selected items to ease serialization
|
||||||
MODULE module( m_board );
|
MODULE module( board() );
|
||||||
|
|
||||||
for( auto item : selection )
|
for( auto item : selection )
|
||||||
{
|
{
|
||||||
|
@ -379,7 +374,7 @@ int MODULE_EDITOR_TOOLS::CopyItems( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the new relative internal local coordinates of copied items
|
// Set the new relative internal local coordinates of copied items
|
||||||
MODULE* editedModule = m_board->m_Modules;
|
MODULE* editedModule = board()->m_Modules;
|
||||||
wxPoint moveVector = module.GetPosition() + editedModule->GetPosition() -
|
wxPoint moveVector = module.GetPosition() + editedModule->GetPosition() -
|
||||||
wxPoint( cursorPos.x, cursorPos.y );
|
wxPoint( cursorPos.x, cursorPos.y );
|
||||||
module.MoveAnchorPosition( moveVector );
|
module.MoveAnchorPosition( moveVector );
|
||||||
|
@ -389,7 +384,7 @@ int MODULE_EDITOR_TOOLS::CopyItems( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->SaveClipboard( data );
|
m_toolMgr->SaveClipboard( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->DisplayToolMsg( wxString::Format( _( "Copied %d item(s)" ), selection.Size() ) );
|
frame()->DisplayToolMsg( wxString::Format( _( "Copied %d item(s)" ), selection.Size() ) );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -409,38 +404,38 @@ int MODULE_EDITOR_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
|
frame()->DisplayToolMsg( _( "Invalid clipboard contents" ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Placement tool part
|
// Placement tool part
|
||||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
||||||
|
|
||||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
// Add a VIEW_GROUP that serves as a preview for the new item
|
||||||
KIGFX::VIEW_GROUP preview( m_view );
|
KIGFX::VIEW_GROUP preview( view() );
|
||||||
pastedModule->SetParent( m_board );
|
pastedModule->SetParent( board() );
|
||||||
pastedModule->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
pastedModule->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||||
pastedModule->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add,
|
pastedModule->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add,
|
||||||
std::ref( preview ), _1 ) );
|
std::ref( preview ), _1 ) );
|
||||||
preview.Add( pastedModule );
|
preview.Add( pastedModule );
|
||||||
m_view->Add( &preview );
|
view()->Add( &preview );
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_controls->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
m_controls->SetSnapping( true );
|
getViewControls()->SetSnapping( true );
|
||||||
m_controls->SetAutoPan( true );
|
getViewControls()->SetAutoPan( true );
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
cursorPos = m_controls->GetCursorPosition();
|
cursorPos = getViewControls()->GetCursorPosition();
|
||||||
|
|
||||||
if( evt->IsMotion() )
|
if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
pastedModule->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
pastedModule->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||||
m_view->Update( &preview );
|
view()->Update( &preview );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->Category() == TC_COMMAND )
|
else if( evt->Category() == TC_COMMAND )
|
||||||
|
@ -448,14 +443,14 @@ int MODULE_EDITOR_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
||||||
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
|
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
|
||||||
{
|
{
|
||||||
const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
|
const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
|
||||||
*m_frame, *evt );
|
*frame(), *evt );
|
||||||
pastedModule->Rotate( pastedModule->GetPosition(), rotationAngle );
|
pastedModule->Rotate( pastedModule->GetPosition(), rotationAngle );
|
||||||
m_view->Update( &preview );
|
view()->Update( &preview );
|
||||||
}
|
}
|
||||||
else if( evt->IsAction( &PCB_ACTIONS::flip ) )
|
else if( evt->IsAction( &PCB_ACTIONS::flip ) )
|
||||||
{
|
{
|
||||||
pastedModule->Flip( pastedModule->GetPosition() );
|
pastedModule->Flip( pastedModule->GetPosition() );
|
||||||
m_view->Update( &preview );
|
view()->Update( &preview );
|
||||||
}
|
}
|
||||||
else if( evt->IsCancel() || evt->IsActivate() )
|
else if( evt->IsCancel() || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
|
@ -466,9 +461,9 @@ int MODULE_EDITOR_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
BOARD_COMMIT commit( m_frame );
|
BOARD_COMMIT commit( frame() );
|
||||||
|
|
||||||
m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
board()->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
||||||
|
|
||||||
// MODULE::RunOnChildren is infeasible here: we need to create copies of items, do not
|
// MODULE::RunOnChildren is infeasible here: we need to create copies of items, do not
|
||||||
// directly modify them
|
// directly modify them
|
||||||
|
@ -506,7 +501,7 @@ int MODULE_EDITOR_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pastedModule;
|
delete pastedModule;
|
||||||
m_view->Remove( &preview );
|
view()->Remove( &preview );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -529,9 +524,9 @@ int MODULE_EDITOR_TOOLS::ModuleTextOutlines( const TOOL_EVENT& aEvent )
|
||||||
for( LAYER_NUM layer : layers )
|
for( LAYER_NUM layer : layers )
|
||||||
settings->SetSketchMode( layer, enable );
|
settings->SetSketchMode( layer, enable );
|
||||||
|
|
||||||
for( MODULE* module = getModel<BOARD>()->m_Modules; module; module = module->Next() )
|
for( auto module : board()->Modules() )
|
||||||
{
|
{
|
||||||
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item ->Next() )
|
for( auto item : module->GraphicalItemsIter() )
|
||||||
{
|
{
|
||||||
if( item->Type() == PCB_MODULE_TEXT_T )
|
if( item->Type() == PCB_MODULE_TEXT_T )
|
||||||
view->Update( item, KIGFX::GEOMETRY );
|
view->Update( item, KIGFX::GEOMETRY );
|
||||||
|
@ -541,7 +536,7 @@ int MODULE_EDITOR_TOOLS::ModuleTextOutlines( const TOOL_EVENT& aEvent )
|
||||||
view->Update( &module->Value(), KIGFX::GEOMETRY );
|
view->Update( &module->Value(), KIGFX::GEOMETRY );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->GetGalCanvas()->Refresh();
|
frame()->GetGalCanvas()->Refresh();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -562,16 +557,16 @@ int MODULE_EDITOR_TOOLS::ModuleEdgeOutlines( const TOOL_EVENT& aEvent )
|
||||||
for( LAYER_NUM layer : layers )
|
for( LAYER_NUM layer : layers )
|
||||||
settings->SetSketchMode( layer, enable );
|
settings->SetSketchMode( layer, enable );
|
||||||
|
|
||||||
for( MODULE* module = getModel<BOARD>()->m_Modules; module; module = module->Next() )
|
for( auto module : board()->Modules() )
|
||||||
{
|
{
|
||||||
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item ->Next() )
|
for( auto item : module->GraphicalItemsIter() )
|
||||||
{
|
{
|
||||||
if( item->Type() == PCB_MODULE_EDGE_T )
|
if( item->Type() == PCB_MODULE_EDGE_T )
|
||||||
view->Update( item, KIGFX::GEOMETRY );
|
view->Update( item, KIGFX::GEOMETRY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->GetGalCanvas()->Refresh();
|
frame()->GetGalCanvas()->Refresh();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#ifndef MODULE_EDITOR_TOOLS_H
|
#ifndef MODULE_EDITOR_TOOLS_H
|
||||||
#define MODULE_EDITOR_TOOLS_H
|
#define MODULE_EDITOR_TOOLS_H
|
||||||
|
|
||||||
#include <tool/tool_interactive.h>
|
#include <tools/pcb_tool.h>
|
||||||
|
|
||||||
namespace KIGFX
|
namespace KIGFX
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ class PCB_EDIT_FRAME;
|
||||||
*
|
*
|
||||||
* Module editor specific tools.
|
* Module editor specific tools.
|
||||||
*/
|
*/
|
||||||
class MODULE_EDITOR_TOOLS : public TOOL_INTERACTIVE
|
class MODULE_EDITOR_TOOLS : public PCB_TOOL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MODULE_EDITOR_TOOLS();
|
MODULE_EDITOR_TOOLS();
|
||||||
|
@ -99,12 +99,6 @@ public:
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void SetTransitions() override;
|
void SetTransitions() override;
|
||||||
|
|
||||||
private:
|
|
||||||
KIGFX::VIEW* m_view;
|
|
||||||
KIGFX::VIEW_CONTROLS* m_controls;
|
|
||||||
BOARD* m_board;
|
|
||||||
PCB_EDIT_FRAME* m_frame;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,49 +37,49 @@
|
||||||
#include <menus_helpers.h>
|
#include <menus_helpers.h>
|
||||||
|
|
||||||
// Placement tool
|
// Placement tool
|
||||||
TOOL_ACTION PCB_ACTIONS::alignTop( "pcbnew.Place.alignTop",
|
TOOL_ACTION PCB_ACTIONS::alignTop( "pcbnew.AlignAndDistribute.alignTop",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "Align to Top" ),
|
_( "Align to Top" ),
|
||||||
_( "Aligns selected items to the top edge" ), up_xpm );
|
_( "Aligns selected items to the top edge" ), up_xpm );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::alignBottom( "pcbnew.Place.alignBottom",
|
TOOL_ACTION PCB_ACTIONS::alignBottom( "pcbnew.AlignAndDistribute.alignBottom",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "Align to Bottom" ),
|
_( "Align to Bottom" ),
|
||||||
_( "Aligns selected items to the bottom edge" ), down_xpm );
|
_( "Aligns selected items to the bottom edge" ), down_xpm );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::alignLeft( "pcbnew.Place.alignLeft",
|
TOOL_ACTION PCB_ACTIONS::alignLeft( "pcbnew.AlignAndDistribute.alignLeft",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "Align to Left" ),
|
_( "Align to Left" ),
|
||||||
_( "Aligns selected items to the left edge" ), left_xpm );
|
_( "Aligns selected items to the left edge" ), left_xpm );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::alignRight( "pcbnew.Place.alignRight",
|
TOOL_ACTION PCB_ACTIONS::alignRight( "pcbnew.AlignAndDistribute.alignRight",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "Align to Right" ),
|
_( "Align to Right" ),
|
||||||
_( "Aligns selected items to the right edge" ), right_xpm );
|
_( "Aligns selected items to the right edge" ), right_xpm );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::distributeHorizontally( "pcbnew.Place.distributeHorizontally",
|
TOOL_ACTION PCB_ACTIONS::distributeHorizontally( "pcbnew.AlignAndDistribute.distributeHorizontally",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "Distribute Horizontally" ),
|
_( "Distribute Horizontally" ),
|
||||||
_( "Distributes selected items along the horizontal axis" ), distribute_horizontal_xpm );
|
_( "Distributes selected items along the horizontal axis" ), distribute_horizontal_xpm );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::distributeVertically( "pcbnew.Place.distributeVertically",
|
TOOL_ACTION PCB_ACTIONS::distributeVertically( "pcbnew.AlignAndDistribute.distributeVertically",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "Distribute Vertically" ),
|
_( "Distribute Vertically" ),
|
||||||
_( "Distributes selected items along the vertical axis" ), distribute_vertical_xpm );
|
_( "Distributes selected items along the vertical axis" ), distribute_vertical_xpm );
|
||||||
|
|
||||||
|
|
||||||
PLACEMENT_TOOL::PLACEMENT_TOOL() :
|
ALIGN_DISTRIBUTE_TOOL::ALIGN_DISTRIBUTE_TOOL() :
|
||||||
TOOL_INTERACTIVE( "pcbnew.Placement" ), m_selectionTool( NULL ), m_placementMenu( NULL )
|
TOOL_INTERACTIVE( "pcbnew.Placement" ), m_selectionTool( NULL ), m_placementMenu( NULL )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PLACEMENT_TOOL::~PLACEMENT_TOOL()
|
ALIGN_DISTRIBUTE_TOOL::~ALIGN_DISTRIBUTE_TOOL()
|
||||||
{
|
{
|
||||||
delete m_placementMenu;
|
delete m_placementMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PLACEMENT_TOOL::Init()
|
bool ALIGN_DISTRIBUTE_TOOL::Init()
|
||||||
{
|
{
|
||||||
// Find the selection tool, so they can cooperate
|
// Find the selection tool, so they can cooperate
|
||||||
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
|
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
|
||||||
|
@ -111,7 +111,7 @@ bool PLACEMENT_TOOL::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignTop( const TOOL_EVENT& aEvent )
|
int ALIGN_DISTRIBUTE_TOOL::AlignTop( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ int PLACEMENT_TOOL::AlignTop( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignBottom( const TOOL_EVENT& aEvent )
|
int ALIGN_DISTRIBUTE_TOOL::AlignBottom( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ int PLACEMENT_TOOL::AlignBottom( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignLeft( const TOOL_EVENT& aEvent )
|
int ALIGN_DISTRIBUTE_TOOL::AlignLeft( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ int PLACEMENT_TOOL::AlignLeft( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PLACEMENT_TOOL::AlignRight( const TOOL_EVENT& aEvent )
|
int ALIGN_DISTRIBUTE_TOOL::AlignRight( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ static bool compareY( const BOARD_ITEM* aA, const BOARD_ITEM* aB )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PLACEMENT_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent )
|
int ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ int PLACEMENT_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PLACEMENT_TOOL::DistributeVertically( const TOOL_EVENT& aEvent )
|
int ALIGN_DISTRIBUTE_TOOL::DistributeVertically( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
|
||||||
|
@ -357,13 +357,13 @@ int PLACEMENT_TOOL::DistributeVertically( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PLACEMENT_TOOL::SetTransitions()
|
void ALIGN_DISTRIBUTE_TOOL::SetTransitions()
|
||||||
{
|
{
|
||||||
Go( &PLACEMENT_TOOL::AlignTop, PCB_ACTIONS::alignTop.MakeEvent() );
|
Go( &ALIGN_DISTRIBUTE_TOOL::AlignTop, PCB_ACTIONS::alignTop.MakeEvent() );
|
||||||
Go( &PLACEMENT_TOOL::AlignBottom, PCB_ACTIONS::alignBottom.MakeEvent() );
|
Go( &ALIGN_DISTRIBUTE_TOOL::AlignBottom, PCB_ACTIONS::alignBottom.MakeEvent() );
|
||||||
Go( &PLACEMENT_TOOL::AlignLeft, PCB_ACTIONS::alignLeft.MakeEvent() );
|
Go( &ALIGN_DISTRIBUTE_TOOL::AlignLeft, PCB_ACTIONS::alignLeft.MakeEvent() );
|
||||||
Go( &PLACEMENT_TOOL::AlignRight, PCB_ACTIONS::alignRight.MakeEvent() );
|
Go( &ALIGN_DISTRIBUTE_TOOL::AlignRight, PCB_ACTIONS::alignRight.MakeEvent() );
|
||||||
|
|
||||||
Go( &PLACEMENT_TOOL::DistributeHorizontally, PCB_ACTIONS::distributeHorizontally.MakeEvent() );
|
Go( &ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally, PCB_ACTIONS::distributeHorizontally.MakeEvent() );
|
||||||
Go( &PLACEMENT_TOOL::DistributeVertically, PCB_ACTIONS::distributeVertically.MakeEvent() );
|
Go( &ALIGN_DISTRIBUTE_TOOL::DistributeVertically, PCB_ACTIONS::distributeVertically.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,18 +22,18 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLACEMENT_TOOL_H_
|
#ifndef ALIGN_DISTRIBUTE_TOOL_H_
|
||||||
#define PLACEMENT_TOOL_H_
|
#define ALIGN_DISTRIBUTE_TOOL_H_
|
||||||
|
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
|
|
||||||
class SELECTION_TOOL;
|
class SELECTION_TOOL;
|
||||||
|
|
||||||
class PLACEMENT_TOOL : public TOOL_INTERACTIVE
|
class ALIGN_DISTRIBUTE_TOOL : public TOOL_INTERACTIVE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PLACEMENT_TOOL();
|
ALIGN_DISTRIBUTE_TOOL();
|
||||||
virtual ~PLACEMENT_TOOL();
|
virtual ~ALIGN_DISTRIBUTE_TOOL();
|
||||||
|
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
void Reset( RESET_REASON aReason ) override {}
|
void Reset( RESET_REASON aReason ) override {}
|
||||||
|
@ -86,4 +86,4 @@ private:
|
||||||
CONTEXT_MENU* m_placementMenu;
|
CONTEXT_MENU* m_placementMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PLACEMENT_TOOL_H_ */
|
#endif /* ALIGN_DISTRIBUTE_TOOL_H_ */
|
||||||
|
|
|
@ -59,7 +59,7 @@ void PCB_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
||||||
aToolManager->RegisterTool( new POINT_EDITOR );
|
aToolManager->RegisterTool( new POINT_EDITOR );
|
||||||
aToolManager->RegisterTool( new PCBNEW_CONTROL );
|
aToolManager->RegisterTool( new PCBNEW_CONTROL );
|
||||||
aToolManager->RegisterTool( new PCB_EDITOR_CONTROL );
|
aToolManager->RegisterTool( new PCB_EDITOR_CONTROL );
|
||||||
aToolManager->RegisterTool( new PLACEMENT_TOOL );
|
aToolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
|
||||||
aToolManager->RegisterTool( new MICROWAVE_TOOL );
|
aToolManager->RegisterTool( new MICROWAVE_TOOL );
|
||||||
aToolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
|
aToolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue