24#include "dialog_table_properties.h"
62#include <wx/filedlg.h>
107 if( !aBoard || !aDimension )
118 aDimension->
GetEnd(), tol );
126 auto constraint = std::make_unique<PCB_CONSTRAINT>( aParent, aType );
127 constraint->AddMember( aDimension->
m_Uuid, aDimAnchor );
128 constraint->AddMember( *arc, aTargetAnchor );
131 aCommit.
Add( constraint.release() );
140 std::optional<VECTOR2I>
end;
142 switch( aDimension->
Type() )
153 std::vector<ENDPOINT_BINDING> bindings =
159 constraint->AddMember( aDimension->
m_Uuid, binding.sourceAnchor );
160 constraint->AddMember( binding.target.m_item, binding.target.m_anchor, binding.target.m_index );
165 aCommit.
Add( constraint.release() );
175 std::vector<PCB_CONSTRAINT*> snaps;
180 aCommit.
Add( entry.constraint.release() );
182 if( entry.needsSolve )
183 snaps.push_back( added );
193 const std::vector<PCB_CONSTRAINT*>& aConstraints )
195 if( aConstraints.empty() )
209 if( !commit.
Empty() )
240 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
249 if(
via.m_Drill > 0 )
251 msg.Printf(
_(
"Via %s, hole %s" ),
257 msg.Printf(
_(
"Via %s" ),
262 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
271 int id = aEvent.GetId();
329 auto activeToolFunctor =
349 auto canCloseOutline =
364 auto canFinishShape =
378 auto tuningToolActive =
384 auto dimensionToolActive =
413 std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
414 viaSizeMenu->SetTool(
this );
415 m_menu->RegisterSubMenu( viaSizeMenu );
416 ctxMenu.
AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
474 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V, 45" ) );
477 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V" ) );
480 m_frame->DisplayConstraintsMsg( wxString(
"" ) );
501 std::optional<VECTOR2D> startingPoint;
502 std::stack<PCB_SHAPE*> committedLines;
515 while(
drawShape( originalEvent, &line, startingPoint, &committedLines ) )
521 std::vector<PCB_CONSTRAINT*> snaps;
529 commit.
Push(
_(
"Draw Line" ) );
532 committedLines.push( line );
536 startingPoint = std::nullopt;
563 std::optional<VECTOR2D> startingPoint;
578 while(
drawShape( originalEvent, &rect, startingPoint,
nullptr ) )
582 bool cancelled =
false;
585 cancelled =
m_frame->ShowTextBoxPropertiesDialog( textbox ) != wxID_OK;
596 commit.
Push( isTextBox ?
_(
"Draw Text Box" ) :
_(
"Draw Rectangle" ) );
606 startingPoint = std::nullopt;
644 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
647 std::vector<VECTOR2D> initialPts;
658 initialPts.push_back( aEvent.
Position() );
671 commit.
Add( arc.release() );
673 std::vector<PCB_CONSTRAINT*> snaps;
678 commit.
Push(
_(
"Draw Arc" ) );
684 arc = std::make_unique<PCB_SHAPE>( parent );
706 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
709 std::vector<VECTOR2D> initialPts;
720 initialPts.push_back( aEvent.
Position() );
733 commit.
Add( arc.release() );
735 std::vector<PCB_CONSTRAINT*> snaps;
740 commit.
Push(
_(
"Draw Elliptical Arc" ) );
746 arc = std::make_unique<PCB_SHAPE>( parent );
768 std::unique_ptr<PCB_SHAPE> bezier = std::make_unique<PCB_SHAPE>( parent );
771 std::vector<VECTOR2D> initialPts;
774 bezier->SetFlags(
IS_NEW );
782 initialPts.push_back( aEvent.
Position() );
796 initialPts.push_back( bezier->GetEnd() );
799 if( bezier->GetEnd() != bezier->GetBezierC2() )
801 VECTOR2D mirroredC1 = bezier->GetEnd()
802 - ( bezier->GetBezierC2() - bezier->GetEnd() );
803 initialPts.push_back( mirroredC1 );
806 PCB_SHAPE* committedBezier = bezier.get();
807 commit.
Add( bezier.release() );
809 std::vector<PCB_CONSTRAINT*> snaps;
814 commit.
Push(
_(
"Draw Bezier" ) );
824 bezier = std::make_unique<PCB_SHAPE>( parent );
826 bezier->SetFlags(
IS_NEW );
841 bool immediateMode =
image !=
nullptr;
843 bool ignorePrimePosition =
false;
859 image->SetPosition( cursorPos );
878 m_view->RecacheAllItems();
903 ignorePrimePosition =
true;
912 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
916 const LSET snapLayers = {
m_frame->GetActiveLayer() };
920 m_controls->ForceCursorPosition(
true, cursorPos );
932 else if( evt->IsActivate() )
934 if(
image && evt->IsMoveTool() )
937 evt->SetPassEvent(
false );
943 m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel image creation." ) );
944 evt->SetPassEvent(
false );
948 if( evt->IsMoveTool() )
951 m_frame->PushTool( originalEvent );
962 wxFileDialog dlg(
m_frame,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
967 bool cancelled =
false;
972 cancelled = dlg.ShowModal() != wxID_OK;
981 if( evt->IsPrime() && !ignorePrimePosition )
983 cursorPos =
grid.Align( evt->Position() );
994 wxString fullFilename = dlg.GetPath();
996 if( wxFileExists( fullFilename ) )
999 if( !
image || !
image->GetReferenceImage().ReadImageFile( fullFilename ) )
1001 wxMessageBox( wxString::Format(
_(
"Could not load image from '%s'." ), fullFilename ) );
1012 m_view->RecacheAllItems();
1017 m_view->ShowPreview(
true );
1021 commit.Add(
image );
1022 commit.Push(
_(
"Place Image" ) );
1044 || evt->IsMotion() ) )
1046 image->SetPosition( cursorPos );
1049 m_view->RecacheAllItems();
1062 evt->SetPassEvent();
1082 m_gridHelper( aDrawingTool.GetManager(), aFrame.GetMagneticItemsSettings() )
1088 std::unique_ptr<PCB_POINT> new_point = std::make_unique<PCB_POINT>(
m_frame.GetModel() );
1091 new_point->SetLayer( layer );
1146 bool ignorePrimePosition =
false;
1193 ignorePrimePosition =
true;
1202 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1206 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1209 m_controls->ForceCursorPosition(
true, cursorPos );
1215 else if( evt->IsCancelInteractive() || (
text && evt->IsAction( &
ACTIONS::undo ) ) )
1222 else if( evt->IsActivate() )
1227 if( evt->IsMoveTool() )
1230 m_frame->PushTool( originalEvent );
1242 else if( evt->IsClick(
BUT_LEFT ) )
1244 bool placing =
text !=
nullptr;
1268 text->SetLayer( layer );
1269 text->SetAttributes( textAttrs );
1270 text->SetTextPos( cursorPos );
1288 else if(
text->GetTextPos() != cursorPos )
1297 if( !
m_view->IsLayerVisible(
text->GetLayer() ) )
1299 m_frame->GetAppearancePanel()->SetLayerVisible(
text->GetLayer(),
true );
1300 m_frame->GetCanvas()->Refresh();
1317 commit.
Push(
_(
"Draw Text" ) );
1329 if( evt->IsPrime() && !ignorePrimePosition )
1331 cursorPos = evt->Position();
1332 m_controls->WarpMouseCursor( cursorPos,
true );
1336 m_controls->PinCursorInsideNonAutoscrollArea(
true );
1348 text->SetPosition( cursorPos );
1366 evt->SetPassEvent();
1441 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1445 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1448 m_controls->ForceCursorPosition(
true, cursorPos );
1454 else if( evt->IsCancelInteractive() || (
table && evt->IsAction( &
ACTIONS::undo ) ) )
1461 else if( evt->IsActivate() )
1466 if( evt->IsMoveTool() )
1469 m_frame->PushTool( originalEvent );
1482 else if( evt->IsClick(
BUT_LEFT ) )
1492 table->SetLayer( layer );
1493 table->SetColCount( 1 );
1496 table->SetLayer( layer );
1497 table->SetPosition( cursorPos );
1499 if( !
m_view->IsLayerVisible( layer ) )
1501 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1502 m_frame->GetCanvas()->Refresh();
1534 commit.
Push(
_(
"Draw Table" ) );
1548 VECTOR2I requestedSize( cursorPos - origin );
1550 int colCount = std::max( 1, requestedSize.
x / ( fontSize.
x * 15 ) );
1551 int rowCount = std::max( 1, requestedSize.
y / ( fontSize.
y * 3 ) );
1553 VECTOR2I cellSize( std::max( fontSize.
x * 5, requestedSize.
x / colCount ),
1554 std::max( fontSize.
y * 3, requestedSize.
y / rowCount ) );
1556 cellSize.
x =
KiROUND( (
double) cellSize.
x / gridSize.
x ) * gridSize.
x;
1557 cellSize.
y =
KiROUND( (
double) cellSize.
y / gridSize.
y ) * gridSize.
y;
1559 table->ClearCells();
1560 table->SetColCount( colCount );
1562 for(
int col = 0; col < colCount; ++col )
1563 table->SetColWidth( col, cellSize.
x );
1565 for(
int row = 0; row < rowCount; ++row )
1567 table->SetRowHeight( row, cellSize.
y );
1569 for(
int col = 0; col < colCount; ++col )
1574 table->AddCell( cell );
1595 evt->SetPassEvent();
1671 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1675 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1678 m_controls->ForceCursorPosition(
true, cursorPos );
1684 else if( evt->IsCancelInteractive() || ( barcode && evt->IsAction( &
ACTIONS::undo ) ) )
1691 else if( evt->IsActivate() )
1696 if( evt->IsMoveTool() )
1699 m_frame->PushTool( originalEvent );
1711 else if( evt->IsClick(
BUT_LEFT ) )
1738 if( !
m_view->IsLayerVisible( layer ) )
1740 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1741 m_frame->GetCanvas()->Refresh();
1744 commit.
Add( barcode );
1745 commit.
Push(
_(
"Draw Barcode" ) );
1755 evt->SetPassEvent();
1779 enum DIMENSION_STEPS
1793 int step = SET_ORIGIN;
1806 m_view->Update( &preview );
1813 dimension =
nullptr;
1843 if( step > SET_ORIGIN )
1844 frame()->SetMsgPanel( dimension );
1851 if( evt->Modifier(
MD_CTRL ) )
1855 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1863 grid.SetUseGrid(
false );
1867 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
1870 m_controls->ForceCursorPosition(
true, cursorPos );
1872 if( evt->IsCancelInteractive() || ( dimension && evt->IsAction( &
ACTIONS::undo ) ) )
1876 if( step != SET_ORIGIN )
1881 else if( evt->IsActivate() )
1883 if( step != SET_ORIGIN )
1886 if( evt->IsPointEditor() )
1892 if( evt->IsMoveTool() )
1895 m_frame->PushTool( originalEvent );
1904 m_view->Update( &preview );
1905 frame()->SetMsgPanel( dimension );
1913 m_view->Update( &preview );
1914 frame()->SetMsgPanel( dimension );
1935 auto setMeasurementAttributes =
1949 setMeasurementAttributes( dimension );
1954 setMeasurementAttributes( dimension );
1963 setMeasurementAttributes( dimension );
1972 wxFAIL_MSG( wxT(
"Unhandled action in DRAWING_TOOL::DrawDimension" ) );
1975 t = dimension->
Type();
1986 dimension->
SetEnd( cursorPos );
1989 if( !
m_view->IsLayerVisible( layer ) )
1991 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1992 m_frame->GetCanvas()->Refresh();
1995 preview.
Add( dimension );
1996 frame()->SetMsgPanel( dimension );
2022 preview.
Remove( dimension );
2024 commit.
Add( dimension );
2030 commit.
Push(
_(
"Draw Dimension" ) );
2034 frame()->OnEditItemRequest( dimension );
2043 dimension =
nullptr;
2048 else if( evt->IsDblClick(
BUT_LEFT ) )
2053 else if( evt->IsMotion() )
2058 dimension->
SetEnd( cursorPos );
2082 textOffset = -textOffset;
2091 textOffset = -textOffset;
2108 double height = (
delta.x * cos( angle ) ) + (
delta.y * sin( angle ) );
2146 ortho->SetHeight( vert ? heightVector.
x : heightVector.
y );
2154 m_view->Update( &preview );
2160 if( !
m_view->IsLayerVisible( layer ) )
2162 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2163 m_frame->GetCanvas()->Refresh();
2173 m_view->Update( &preview );
2174 frame()->SetMsgPanel( dimension );
2178 if( step == SET_END || step == SET_HEIGHT )
2180 frame()->OnEditItemRequest( dimension );
2182 frame()->SetMsgPanel( dimension );
2192 switch( dimension->
Type() )
2207 m_view->Update( &preview );
2216 evt->SetPassEvent();
2220 if( step != SET_ORIGIN )
2228 m_view->Remove( &preview );
2257 if( dlgResult != wxID_OK )
2263 wxMessageBox(
_(
"No graphic items found in file.") );
2269 std::vector<BOARD_ITEM*> newItems;
2270 std::vector<BOARD_ITEM*> selectedItems;
2278 size_t boardItemCount = std::count_if( list.begin(), list.end(),
2279 [](
const std::unique_ptr<EDA_ITEM>& ptr )
2281 return ptr->IsBOARD_ITEM();
2284 if( boardItemCount >= 2 )
2288 newItems.push_back(
group );
2289 selectedItems.push_back(
group );
2296 std::vector<PCB_SHAPE*> shapeList;
2298 for(
const std::unique_ptr<EDA_ITEM>& ptr : list )
2301 shapeList.push_back( shape );
2307 for( std::unique_ptr<EDA_ITEM>& ptr : list )
2309 EDA_ITEM* eda_item = ptr.release();
2315 newItems.push_back( item );
2318 group->AddItem( item );
2320 selectedItems.push_back( item );
2325 preview.
Add( eda_item );
2331 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
2339 commit.
Push(
_(
"Import Graphics" ) );
2347 if( !
m_view->IsLayerVisible( layer ) )
2349 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2350 m_frame->GetCanvas()->Refresh();
2378 item->Move(
delta );
2380 m_view->Update( &preview );
2388 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2391 m_controls->ForceCursorPosition(
true, cursorPos );
2393 if( evt->IsCancelInteractive() || evt->IsActivate() )
2405 else if( evt->IsMotion() )
2410 item->Move(
delta );
2412 m_view->Update( &preview );
2424 commit.
Push(
_(
"Import Graphics" ) );
2434 evt->SetPassEvent();
2439 m_view->Remove( &preview );
2489 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2491 m_controls->ForceCursorPosition(
true, cursorPos );
2501 footprint->MoveAnchorPosition( moveVector );
2503 commit.
Push(
_(
"Move Footprint Anchor" ) );
2512 else if( evt->IsCancelInteractive() || evt->IsActivate() )
2518 evt->SetPassEvent();
2547 int step = SET_CENTER;
2590 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2592 m_controls->ForceCursorPosition(
true, cursorPos );
2596 if( step == SET_CENTER )
2605 board->Add( griditem );
2612 sizeToCursor( cursorPos );
2617 board->Remove( griditem );
2620 commit.
Add( griditem );
2621 commit.
Push(
_(
"Place a local grid item" ) );
2631 else if( evt->IsCancelInteractive() || evt->IsActivate() || ( griditem && evt->IsAction( &
ACTIONS::undo ) ) )
2633 bool restart = griditem && !evt->IsActivate();
2638 board->Remove( griditem );
2648 else if( griditem && evt->IsMotion() )
2650 sizeToCursor( cursorPos );
2655 evt->SetPassEvent();
2672 const double cosRot = rot.
Cos();
2673 const double sinRot = rot.
Sin();
2675 const double dx = aCursorPos.
x -
center.x;
2676 const double dy = aCursorPos.
y -
center.y;
2677 const double lx = dx * cosRot + dy * sinRot;
2678 const double ly = -dx * sinRot + dy * cosRot;
2681 const double px = a * t.
Cos();
2682 const double py = b * t.
Sin();
2705 if( halfW >= halfH )
2707 majorRadius = std::max( halfW, 1 );
2708 minorRadius = std::max( halfH, 1 );
2713 majorRadius = std::max( halfH, 1 );
2714 minorRadius = std::max( halfW, 1 );
2739 std::stack<PCB_SHAPE*>* aCommittedGraphics )
2741 SHAPE_T shape = ( *aGraphic )->GetShape();
2783 m_view->Add( &twoPointAsst );
2785 bool started =
false;
2786 bool cancelled =
false;
2787 bool multiPhase =
false;
2789 bool isLocalOriginSet = (
m_frame->GetScreen()->m_LocalOrigin !=
VECTOR2D( 0, 0 ) );
2809 if( !isLocalOriginSet )
2820 if( aStartingPoint )
2821 m_toolMgr->PrimeTool( *aStartingPoint );
2829 m_frame->SetMsgPanel( graphic );
2839 if( evt->Modifier(
MD_CTRL ) )
2846 if( evt->Modifier(
MD_CTRL ) )
2850 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2854 m_controls->ForceCursorPosition(
true, cursorPos );
2856 if( evt->IsCancelInteractive() || ( started && evt->IsAction( &
ACTIONS::undo ) ) )
2863 evt->SetPassEvent(
false );
2869 else if( evt->IsActivate() )
2871 if( evt->IsPointEditor() )
2877 if( evt->IsMoveTool() )
2910 m_frame->GetCanvas()->Refresh();
2920 frame()->SetMsgPanel( graphic );
2924 evt->SetPassEvent();
2943 if( aStartingPoint )
2945 cursorPos = *aStartingPoint;
2946 aStartingPoint = std::nullopt;
2961 grid.SetSkipPoint( cursorPos );
2964 twoPointMgr.
SetEnd( cursorPos );
2966 if( !isLocalOriginSet )
2967 m_frame->GetScreen()->m_LocalOrigin = cursorPos;
2970 frame()->SetMsgPanel( graphic );
2977 m_frame->GetCanvas()->Refresh();
2987 else if( multiPhase )
3012 m_view->Remove( &twoPointAsst );
3024 commit.
Add( graphic );
3026 std::vector<PCB_CONSTRAINT*> snaps;
3034 commit.
Push(
_(
"Draw Line" ) );
3048 twoPointMgr.
Reset();
3055 else if( evt->IsMotion() )
3081 frame()->SetMsgPanel( graphic );
3085 VECTOR2I clampedCursorPos = cursorPos;
3109 twoPointMgr.
SetEnd( clampedCursorPos );
3115 m_view->Update( &twoPointAsst );
3121 if( aCommittedGraphics && !aCommittedGraphics->empty() )
3123 twoPointMgr.
SetOrigin( aCommittedGraphics->top()->GetStart() );
3124 twoPointMgr.
SetEnd( aCommittedGraphics->top()->GetEnd() );
3125 aCommittedGraphics->pop();
3142 m_view->Update( &twoPointAsst );
3155 frame()->SetMsgPanel( graphic );
3164 frame()->SetMsgPanel( graphic );
3169 frame()->OnEditItemRequest( graphic );
3171 frame()->SetMsgPanel( graphic );
3180 isLocalOriginSet =
true;
3181 evt->SetPassEvent();
3185 if(
frame()->GetUserUnits() != userUnits )
3187 userUnits =
frame()->GetUserUnits();
3188 twoPointAsst.
SetUnits( userUnits );
3189 m_view->Update( &twoPointAsst );
3191 evt->SetPassEvent();
3195 evt->SetPassEvent();
3199 if( !isLocalOriginSet )
3203 m_view->Remove( &twoPointAsst );
3221 const std::vector<VECTOR2D>& aInitialPts )
3262 bool started =
false;
3263 bool cancelled =
false;
3264 bool finished =
false;
3270 for(
const VECTOR2D& pt : aInitialPts )
3273 if( !aInitialPts.empty() )
3287 m_frame->GetCanvas()->Refresh();
3290 preview.
Add( graphic );
3291 frame()->SetMsgPanel( graphic );
3300 m_frame->SetMsgPanel( graphic );
3309 if( evt->Modifier(
MD_CTRL ) )
3312 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3315 m_controls->ForceCursorPosition(
true, cursorPos );
3317 if( evt->IsCancelInteractive() )
3324 evt->SetPassEvent(
false );
3335 else if( evt->IsActivate() )
3337 if( evt->IsPointEditor() )
3343 if( evt->IsMoveTool() )
3353 else if( evt->IsClick(
BUT_LEFT ) )
3369 m_frame->GetCanvas()->Refresh();
3372 preview.
Add( graphic );
3373 frame()->SetMsgPanel( graphic );
3379 else if( evt->IsDblClick(
BUT_LEFT )
3398 else if( evt->IsMotion() )
3421 m_frame->GetCanvas()->Refresh();
3426 m_view->Update( &preview );
3427 frame()->SetMsgPanel( graphic );
3431 evt->SetPassEvent();
3438 frame()->OnEditItemRequest( graphic );
3439 m_view->Update( &preview );
3440 frame()->SetMsgPanel( graphic );
3445 evt->SetPassEvent();
3462 m_view->Update( &preview );
3463 frame()->SetMsgPanel( graphic );
3475 m_view->Update( &preview );
3476 frame()->SetMsgPanel( graphic );
3488 evt->SetPassEvent();
3497 evt->SetPassEvent();
3507 m_view->Update( &preview );
3512 frame()->SetMsgPanel( graphic );
3518 preview.
Remove( graphic );
3520 m_view->Remove( &preview );
3542 bool clearSelection =
false;
3554 clearSelection =
true;
3565 if( clearSelection )
3604 ZONE* sourceZone =
nullptr;
3616 params.
m_mode = zoneMode;
3627 bool started =
false;
3641 polyGeomMgr.
Reset();
3643 grid.ClearSkipPoint();
3672 if( evt->Modifier(
MD_CTRL ) )
3675 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3677 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
3680 m_controls->ForceCursorPosition(
true, cursorPos );
3684 if( evt->IsCancelInteractive() )
3693 evt->SetPassEvent(
false );
3697 else if( evt->IsActivate() )
3702 if( evt->IsPointEditor() )
3708 if( evt->IsMoveTool() )
3711 m_frame->PushTool( originalEvent );
3723 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
3724 m_frame->GetCanvas()->Refresh();
3740 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
3747 polyGeomMgr.
Reset();
3753 else if( polyGeomMgr.
AddPoint( cursorPos ) )
3764 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
3765 m_frame->GetCanvas()->Refresh();
3780 cursorPos = last.value();
3782 m_controls->ForceCursorPosition(
true, cursorPos );
3790 else if( started && ( evt->IsMotion()
3816 evt->SetPassEvent();
3844 worst = std::max( worst, constraint.
GetValue().
Min() );
3848 for(
PAD*
pad : footprint->Pads() )
3850 std::optional<int> padOverride =
pad->GetClearanceOverrides(
nullptr );
3852 if( padOverride.has_value() )
3853 worst = std::max( worst, padOverride.value() );
3867 auto sub_e = [&](
int aClearance )
3869 return std::max( 0, aClearance - aEpsilon );
3875 ZONE* zone =
dynamic_cast<ZONE*
>( aOther );
3889 zoneOutline = zone->
Outline();
3896 via->Padstack().ForEachUniqueLayer(
3902 if(
via->IsGhostLayer( aLayer ) )
3905 if( zoneOutline->
Collide(
via->GetPosition(),
via->GetWidth( aLayer ) / 2 ) )
3917 int connectedItemNet = connectedItem->
GetNetCode();
3919 if( connectedItemNet == 0 || connectedItemNet == aItem->
GetNetCode() )
3937 if( itemShape->Collide( otherShape.get(), sub_e(
clearance ) ) )
3961 int aWorstClearance,
int aEpsilon )
3963 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3964 std::set<BOARD_ITEM*> checkedItems;
3967 bbox.
Inflate( aWorstClearance );
3970 for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
3972 if( !it.first->IsBOARD_ITEM() )
3990 else if( checkedItems.count( item ) )
3998 checkedItems.insert( item );
4034 const LSET& aLayers,
int aSnapRange )
4036 const LSET lset = aLayers;
4039 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4041 std::vector<PCB_TRACK*> possible_tracks;
4043 wxCHECK( view,
nullptr );
4045 view->
Query( bbox, items );
4049 if( !it.first->IsBOARD_ITEM() )
4065 possible_tracks.push_back( track );
4073 possible_tracks.push_back( arc );
4078 int min_d = std::numeric_limits<int>::max();
4080 for(
PCB_TRACK* track : possible_tracks )
4082 SEG test( track->GetStart(), track->GetEnd() );
4083 int dist = (
test.NearestPoint( aPosition ) - aPosition ).EuclideanNorm();
4088 return_track = track;
4092 return return_track;
4099 const LSET lset = aLayers;
4103 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4105 view.
Query( bbox, items );
4109 if( !it.first->IsBOARD_ITEM() )
4118 if(
pad.HitTest( aPosition, aSnapRange ) )
4128 const LSET& aLayers,
int aSnapRange = 0 )
4133 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4136 std::vector<PCB_SHAPE*> possible_shapes;
4138 view->
Query( bbox, items );
4142 if( !it.first->IsBOARD_ITEM() )
4154 if( shape->
HitTest( aPosition, std::max( aVia->
GetWidth( activeLayer ) / 2, aSnapRange ) ) )
4155 possible_shapes.push_back( shape );
4160 int min_d = std::numeric_limits<int>::max();
4162 for(
PCB_SHAPE* shape : possible_shapes )
4164 int dist = ( shape->GetPosition() - aPosition ).EuclideanNorm();
4169 return_shape = shape;
4173 return return_shape;
4191 std::shared_ptr<DRC_ENGINE> m_drcEngine;
4193 int m_worstClearance;
4194 bool m_allowDRCViolations;
4196 int sub_e(
int aClearance )
4198 return std::max( 0, aClearance - m_drcEpsilon );
4206 m_worstClearance( 0 )
4216 virtual ~VIA_PLACER()
4219 bool checkDRCViolation(
PCB_VIA* aVia )
4239 std::optional<int> selectPossibleNetsByPopupMenu( std::set<int>& aNetcodeList )
4243 std::map<int, int> menuIDNetCodeMap;
4246 for(
int netcode : aNetcodeList )
4253 menuText = wxString::Format(
"%s\t",
4256 menuText = wxString::Format(
"&%d %s\t",
4267 menuIDNetCodeMap[ menuID ] = netcode;
4277 int selectedNetCode = -1;
4278 bool cancelled =
false;
4284 evt->SetPassEvent();
4288 std::optional<int>
id = evt->GetCommandId();
4291 if(
id && ( *
id > 0 ) && ( *
id < menuID ) )
4293 selectedNetCode = menuIDNetCodeMap.at( *
id );
4308 return std::optional<int>();
4310 return selectedNetCode;
4313 std::optional<int> findStitchedZoneNet(
PCB_VIA* aVia )
4317 std::set<int> netcodeList;
4327 if( z->IsOnLayer(
m_frame->GetActiveLayer() ) )
4329 if( z->HitTestFilledArea(
m_frame->GetActiveLayer(), position ) )
4330 netcodeList.insert( z->GetNetCode() );
4337 if( netcodeList.size() == 1 )
4338 return *netcodeList.begin();
4345 if( z->GetIsRuleArea() )
4350 if( z->IsOnLayer( layer ) )
4352 if( z->HitTestFilledArea( layer, position ) )
4353 netcodeList.insert( z->GetNetCode() );
4359 if( netcodeList.size() == 1 )
4360 return *netcodeList.begin();
4362 if( netcodeList.size() > 1 )
4365 return selectPossibleNetsByPopupMenu( netcodeList );
4390 SEG trackSeg( track->GetStart(), track->GetEnd() );
4400 if(
PAD*
pad = findPad(
via, position ) )
4411 if( shape->IsAnyFill() )
4417 double shapeArea = poly.
Area();
4419 int R =
via->GetWidth( shape->GetLayer() ) / 2;
4420 double viaArea =
M_PI * R * R;
4422 if( viaArea * 4 > shapeArea )
4427 switch( shape->GetShape() )
4431 SEG seg( shape->GetStart(), shape->GetEnd() );
4439 if( ( shape->GetEnd() - position ).SquaredEuclideanNorm() <
4440 ( shape->GetStart() - position ).SquaredEuclideanNorm() )
4454 if( !shape->IsPolyShapeValid() )
4461 std::optional<SEG> nearestSeg;
4462 int minDist = std::numeric_limits<int>::max();
4471 int dist = seg.
Distance( position );
4473 if( dist < minDist )
4512 via->SetIsFree(
false );
4516 via->SetNetCode(
pad->GetNetCode() );
4517 via->SetIsFree(
false );
4522 via->SetIsFree(
false );
4526 std::optional<int> netcode = findStitchedZoneNet(
via );
4528 if( !netcode.has_value() )
4531 via->SetNetCode( netcode.value() );
4532 via->SetIsFree(
via->GetNetCode() > 0 );
4535 if( checkDRCViolation(
via ) )
4537 m_frame->ShowInfoBarError(
_(
"Via location violates DRC." ),
true,
4538 WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
4540 if( !m_allowDRCViolations )
4545 if( infobar->
GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION )
4554 if( track && m_gridHelper.
GetSnap() )
4558 SEG trackSeg( trackStart, trackEnd );
4560 if( viaPos == trackStart || viaPos == trackEnd )
4574 newTrack->
SetEnd( trackEnd );
4575 aCommit.
Add( newTrack );
4581 std::unique_ptr<BOARD_ITEM> CreateItem()
override
4586 via->SetNetCode( 0 );
4600 if( first_layer !=
m_frame->GetScreen()->m_Route_Layer_TOP )
4601 last_layer =
m_frame->GetScreen()->m_Route_Layer_TOP;
4603 last_layer =
m_frame->GetScreen()->m_Route_Layer_BOTTOM;
4605 via->SetLayerPair( first_layer, last_layer );
4611 via->SetDrill(
via->GetEffectiveNetClass()->GetuViaDrill() );
4619 return std::unique_ptr<BOARD_ITEM>(
via );
4623 VIA_PLACER placer(
frame() );
4634 const wxString& aCommitLabel,
4648 std::optional<VECTOR2D> startingPoint;
4670 while( aDrawer( originalEvent, &shape, startingPoint ) )
4674 commit.
Add( shape );
4676 std::vector<PCB_CONSTRAINT*> snaps;
4681 commit.
Push( aCommitLabel );
4686 shape = makeShape();
4687 startingPoint = std::nullopt;
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
CONSTRAINT_DIAGNOSIS ApplyConstraintImmediately(BOARD *aBoard, const PCB_CONSTRAINT *aConstraint, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::set< KIID > &aFixedShapes)
Solve a just-created constraint's cluster so the geometry snaps to satisfy it (SolidWorks-style),...
@ HIDDEN
Inactive layers are hidden.
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION arcPosture
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
static TOOL_ACTION updateUnits
static TOOL_ACTION deleteLastPoint
static TOOL_ACTION cursorDblClick
static TOOL_ACTION activatePointEditor
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION refreshPreview
static TOOL_ACTION finishInteractive
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static TOOL_ACTION resetLocalCoords
Interactive arc drawing behaviour: center -> start -> end angle.
Interactive bezier drawing behaviour: start -> control1 -> end -> control2.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Container for design settings for a BOARD object.
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
VIATYPE m_CurrentViaType
(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
DIM_UNITS_FORMAT m_DimensionUnitsFormat
bool GetTextUpright(PCB_LAYER_ID aLayer) const
int GetTextThickness(PCB_LAYER_ID aLayer) const
Return the default text thickness from the layer class for the given layer.
bool GetTextItalic(PCB_LAYER_ID aLayer) const
int GetCurrentViaSize() const
void SetViaSizeIndex(int aIndex)
Set the current via size list index to aIndex.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
bool m_UseConnectedTrackWidth
int GetViaSizeIndex() const
bool m_DimensionSuppressZeroes
int GetDRCEpsilon() const
Return an epsilon which accounts for rounding errors, etc.
bool m_DimensionKeepTextAligned
VECTOR2I GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
int GetCurrentViaDrill() const
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
std::vector< VIA_DIMENSION > m_ViasDimensionsList
int m_DimensionExtensionOffset
int m_DimensionArrowLength
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual bool HasHole() const
Information pertinent to a Pcbnew printed circuit board.
const FOOTPRINTS & Footprints() const
wxString GetDesignRulesPath() const
Return the absolute path to the design rules file for this board.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
DIALOG_BARCODE_PROPERTIES, derived from DIALOG_BARCODE_PROPERTIES_BASE, created by wxFormBuilder.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
bool ShouldFixDiscontinuities()
void SetFilenameOverride(const wxString &aFilenameOverride)
Set the filename override to be applied in TransferDataToWindow.
bool IsPlacementInteractive()
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
SEVERITY GetSeverity() const
const MINOPTMAX< int > & GetValue() const
Design Rule Checker object that performs all the DRC tests.
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
bool QueryWorstConstraint(DRC_CONSTRAINT_T aRuleId, DRC_CONSTRAINT &aConstraint, bool aUnconditionalOnly=false)
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
virtual void ClearEditFlags()
virtual void SetPosition(const VECTOR2I &aPos)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
int GetEllipseMinorRadius() const
const VECTOR2I & GetEllipseCenter() const
int GetEllipseMajorRadius() const
EDA_ANGLE GetEllipseRotation() const
virtual void SetFilled(bool aFlag)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
virtual bool IsVisible() const
virtual void SetTextPos(const VECTOR2I &aPoint)
void SetMirrored(bool isMirrored)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Interactive elliptical-arc drawing behaviour: bbox corner 1 -> bbox corner 2 -> start angle -> end an...
A color representation with 4 components: red, green, blue, alpha.
VECTOR2D GetVisibleGridSize() const
Return the visible grid size in x and y directions.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Represents an assistant draw when interactively drawing a line or circle on a canvas.
void SetUnits(EDA_UNITS aUnits)
Represent a very simple geometry manager for items that have a start and end point.
void SetOrigin(const VECTOR2I &aOrigin)
< Set the origin of the ruler (the fixed end)
void SetAngleSnap(LEADER_MODE aSnap)
VECTOR2I GetOrigin() const
void Reset()
Reset the manager to the initial state.
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
bool IsBOARD_ITEM() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
GAL * GetGAL() const
Return the GAL this view is using to draw graphical primitives.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
static const LSET & AllLayersMask()
const wxString & GetNetname() const
Container for NETINFO_ITEM elements, which are the nets.
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
NETINFO_ITEM * GetNetItem(int aNetCode) const
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static TOOL_ACTION drawRuleArea
static TOOL_ACTION changeDimensionArrows
Switch between dimension arrow directions.
static TOOL_ACTION drawBezier
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION setAnchor
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION drawCircle
static TOOL_ACTION tuneDiffPair
static TOOL_ACTION trackViaSizeChanged
static TOOL_ACTION layerChanged
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION drawTable
static TOOL_ACTION drawTextBox
static TOOL_ACTION drawZoneCutout
static TOOL_ACTION drawPolygon
static TOOL_ACTION drawViaStitchArea
static TOOL_ACTION drawRadialDimension
static TOOL_ACTION tuneSingleTrack
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION drawLeader
static TOOL_ACTION drawCopperThievingZone
static TOOL_ACTION tuneSkew
static TOOL_ACTION incWidth
Increase width of currently drawn line.
static TOOL_ACTION drawEllipse
static TOOL_ACTION clearHighlight
static TOOL_ACTION spacingDecrease
static TOOL_ACTION placeImportedGraphics
static TOOL_ACTION drawVia
static TOOL_ACTION drawArc
static TOOL_ACTION drawSimilarZone
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
static TOOL_ACTION drawCenterDimension
static TOOL_ACTION ddImportGraphics
static TOOL_ACTION placeGridItem
Grid Item.
static TOOL_ACTION placeBarcode
static TOOL_ACTION placePoint
static TOOL_ACTION closeOutline
static TOOL_ACTION amplIncrease
static TOOL_ACTION amplDecrease
static TOOL_ACTION lengthTunerSettings
static TOOL_ACTION spacingIncrease
static TOOL_ACTION drawLine
static TOOL_ACTION placeViaStack
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION drawZone
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void SetTextSize(int aTextSize)
Change the height of the human-readable text displayed below the barcode.
void SetPosition(const VECTOR2I &aPos) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the drawing layer for the barcode and its text.
Common, abstract interface for edit frames.
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual PCB_LAYER_ID GetActiveLayer() const
A geometric constraint between board items (issue #2329).
void Update()
Update the dimension's cached text and geometry.
virtual void SetEnd(const VECTOR2I &aPoint)
int GetLineThickness() const
virtual void SetStart(const VECTOR2I &aPoint)
void SetExtensionOffset(int aOffset)
void SetLineThickness(int aWidth)
void SetArrowLength(int aLength)
DIM_ARROW_DIRECTION GetArrowDirection() const
virtual VECTOR2I GetEnd() const
void SetArrowDirection(const DIM_ARROW_DIRECTION &aDirection)
virtual VECTOR2I GetStart() const
The dimension's origin is the first feature point for the dimension.
int GetArrowLength() const
For better understanding of the points that make a dimension:
double GetAngle() const
Return the angle of the crossbar.
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
The main frame for Pcbnew.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
void SetPosition(const VECTOR2I &aPos) override
void SetOrientation(const EDA_ANGLE &aAngle)
void SetExtent(const VECTOR2I &aExtent)
VECTOR2I GetPosition() const override
A set of BOARD_ITEMs (i.e., without duplicates).
Object to handle a bitmap image that can be inserted in a PCB.
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
void SetEllipseCenter(const VECTOR2I &aPt) override
void EndEdit(bool aClosed=true)
void CalcEdit(const VECTOR2I &aPosition)
void SetEditState(int aState)
void SetEllipseStartAngle(const EDA_ANGLE &aA) override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void SetShape(SHAPE_T aShape) override
void SetPosition(const VECTOR2I &aPos) override
void SetEllipseEndAngle(const EDA_ANGLE &aA) override
void SetEnd(const VECTOR2I &aEnd) override
void SetEllipseRotation(const EDA_ANGLE &aA) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetEllipseMinorRadius(int aR) override
void SetStart(const VECTOR2I &aStart) override
bool ContinueEdit(const VECTOR2I &aPosition)
void SetStroke(const STROKE_PARAMS &aStroke) override
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
VECTOR2I GetPosition() const override
void SetEllipseMajorRadius(int aR) override
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
virtual int GetWidth() const
VECTOR2I GetPosition() const override
int GetWidth() const override
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual COMMON_SETTINGS * GetCommonSettings() const
A holder to handle information on schematic or board items.
ROUTING_SETTINGS & Settings()
bool AllowDRCViolations() const
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...
bool AddPoint(const VECTOR2I &aPt)
Lock in a polygon point.
void SetCursorPosition(const VECTOR2I &aPos)
Set the current cursor position.
bool NewPointClosesOutline(const VECTOR2I &aPt) const
std::optional< VECTOR2I > DeleteLastCorner()
Remove the last-added point from the polygon.
void SetFinished()
Mark the polygon finished and update the client.
void SetLeaderMode(LEADER_MODE aMode)
Set the leader mode to use when calculating the leader/returner lines.
void Reset()
Clear the manager state and start again.
RAII class that sets an value at construction and resets it to the original value at destruction.
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
bool Contains(const SEG &aSeg) const
virtual void Add(EDA_ITEM *aItem)
A null aItem is ignored; the selection never holds null members.
virtual void Remove(EDA_ITEM *aItem)
virtual void Clear() override
Remove all the stored items from the group.
void SetReferencePoint(const VECTOR2I &aP)
Abstract interface for interactive shape-drawing behaviours.
virtual void AddPoint(const VECTOR2I &aPosition)=0
Lock in a point and advance the construction state.
virtual void Reset()=0
Reset the behaviour to its initial state for chained object creation loops.
virtual bool IsComplete() const =0
True when all points have been locked in.
virtual void SetCursorPosition(const VECTOR2I &aPosition)=0
Preview the cursor position without advancing state.
virtual void SetUnits(EDA_UNITS aUnits)=0
Forward a units change to the assistant overlay.
virtual bool HasGeometryChanged() const =0
True if the geometry changed since the last call to ClearGeometryChanged().
virtual void RemoveLastPoint()=0
Undo the last locked-in point.
virtual EDA_ITEM & GetAssistant()=0
Return the visual assistant overlay item.
virtual void ClearGeometryChanged()=0
Reset the geometry-changed flag (call after updating the preview).
virtual void ApplyToShape(EDA_SHAPE &aShape) const =0
Transfer the current geometry to an EDA_SHAPE.
virtual void SetAngleSnap(bool aSnap)
Enable or disable angle snapping (circular arcs only; no-op for others).
virtual bool OnProperties(EDA_SHAPE &aShape)
Called when the user invokes the properties action mid-draw.
virtual void ToggleClockwise()
Flip arc direction (applies only when the shape has such a concept of directionality,...
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual const SEG GetSegment(int aIndex) const override
int SegmentCount() const
Return the number of segments in this line chain.
Represent a set of closed polygons.
double Area()
Return the area of this poly set.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
Simple container to manage line stroke parameters.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
A modified version of the wxInfoBar class that allows us to:
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
MESSAGE_TYPE GetMessageType() const
void OnGeometryChange(const POLYGON_GEOM_MANAGER &aMgr) override
Called when the polygon is complete.
Handle a list of polygons defining a copper zone.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
bool GetDoNotAllowVias() const
bool GetDoNotAllowTracks() const
SHAPE_POLY_SET * Outline()
SHAPE_POLY_SET GetBoardOutline() const
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
PCB_LAYER_ID GetFirstLayer() const
This file is part of the common library.
std::vector< AUTO_CONSTRAINT > SelectShapeAutoConstraints(BOARD *aBoard, const PCB_SHAPE *aShape, BOARD_ITEM *aParent, bool aAxisConstraint)
Choose the constraints a freshly drawn shape should get from what its features landed on.
std::optional< KIID > SelectRadialDimensionTarget(BOARD *aBoard, const KIID &aDimension, const VECTOR2I &aCenter, const VECTOR2I &aRim, double aMaxDist)
Single circle or arc a radial dimension binds to or std::nullopt.
std::vector< ENDPOINT_BINDING > SelectEndpointBindings(BOARD *aBoard, const KIID &aItem, const VECTOR2I &aStart, const std::optional< VECTOR2I > &aEnd, double aMaxDist, PCB_LAYER_ID aLayer)
Choose the coincident bindings a freshly drawn item endpoints should take so it tracks the geometry i...
bool ConstraintIsDuplicateOnBoard(BOARD *aBoard, const PCB_CONSTRAINT *aConstraint)
True if the board or one of its footprints already carries an equal constraint.
@ HOLE_CLEARANCE_CONSTRAINT
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_360
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
void ConnectBoardShapes(std::vector< PCB_SHAPE * > &aShapeList, int aChainingEpsilon)
Connects shapes to each other, making continious contours (adjacent shapes will have a common vertex)...
a few functions useful in geometry calculations.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
LEADER_MODE
The kind of the leader line.
@ DIRECT
Unconstrained point-to-point.
VECTOR2< T > GetVectorSnapped90(const VECTOR2< T > &aVec)
Snap a vector onto the nearest horizontal or vertical line.
static wxString ImageFileWildcard()
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_FILLED_SHAPES
Copper graphic shape opacity/visibility (color ignored).
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored).
@ LAYER_SUBGRIDS
Routing/placement subgrids (PCB_GRID_ITEM) visibility and color.
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ SIMILAR
Add a new zone with the same settings as an existing one.
@ ADD
Add a new zone/keepout with fresh settings.
BARCODE class definition.
CONSTRAINT_ANCHOR
Which feature of a referenced board item participates in a constraint.
@ WHOLE
The item as a whole (a segment as a line, a circle).
@ START
First endpoint of a segment or arc.
@ END
Second endpoint of a segment or arc.
@ CENTER
Center of an arc or circle.
PCB_CONSTRAINT_TYPE
The geometric relationship a PCB_CONSTRAINT enforces between its members.
@ COINCIDENT
Two points are made to coincide.
@ POINT_ON_LINE
A point lies on a segment's supporting line.
Class to handle a set of BOARD_ITEMs.
@ ID_POPUP_PCB_SELECT_CUSTOM_WIDTH
@ ID_POPUP_PCB_SELECT_VIASIZE1
@ ID_POPUP_PCB_SELECT_VIASIZE16
PGM_BASE & Pgm()
The global program "get" accessor.
Class that computes missing connections on a PCB.
std::vector< EDA_ITEM * > EDA_ITEMS
SHAPE_DRAW_RESULT
Outcome of an interactive shape drawing loop, telling the caller how to continue.
@ NEXT_SHAPE
Commit the shape, if any, and start drawing another.
@ FINISHED
The user finished; commit the shape, if any, and stop drawing.
@ CANCELLED
The user cancelled; nothing to commit, stop drawing.
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
LINE_STYLE
Dashed line types.
One constraint chosen for a freshly drawn shape.
One of a drawn item feature points bound coincident to an object anchor by draw time auto constrain s...
A filename or source description, a problem input line, a line number, a byte offset,...
std::unique_ptr< BOARD_ITEM > CreateItem() override
DRAWING_TOOL & m_drawingTool
PCB_BASE_EDIT_FRAME & m_frame
PCB_GRID_HELPER m_gridHelper
void SnapItem(BOARD_ITEM *aItem) override
POINT_PLACER(DRAWING_TOOL &aDrawingTool, PCB_BASE_EDIT_FRAME &aFrame)
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
Parameters used to fully describe a zone creation process.
bool m_thieving
Layer to begin drawing.
ZONE_MODE m_mode
Zone settings source (for similar and cutout zones)
bool m_keepout
< Should create a keepout zone?
ZONE * m_sourceZone
Zone leader mode.
PCB_LAYER_ID m_layer
The zone mode to operate in.
wxString result
Test unit parsing edge cases and error handling.
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
Definition of file extensions used in Kicad.