24#include "dialog_table_properties.h"
62#include <wx/filedlg.h>
106 if( !aBoard || !aDimension )
117 aDimension->
GetEnd(), tol );
125 auto constraint = std::make_unique<PCB_CONSTRAINT>( aParent, aType );
126 constraint->AddMember( aDimension->
m_Uuid, aDimAnchor );
127 constraint->AddMember( *arc, aTargetAnchor );
130 aCommit.
Add( constraint.release() );
139 std::optional<VECTOR2I>
end;
141 switch( aDimension->
Type() )
152 std::vector<ENDPOINT_BINDING> bindings =
158 constraint->AddMember( aDimension->
m_Uuid, binding.sourceAnchor );
159 constraint->AddMember( binding.target.m_item, binding.target.m_anchor, binding.target.m_index );
164 aCommit.
Add( constraint.release() );
174 std::vector<PCB_CONSTRAINT*> snaps;
179 aCommit.
Add( entry.constraint.release() );
181 if( entry.needsSolve )
182 snaps.push_back( added );
192 const std::vector<PCB_CONSTRAINT*>& aConstraints )
194 if( aConstraints.empty() )
208 if( !commit.
Empty() )
239 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
248 if(
via.m_Drill > 0 )
250 msg.Printf(
_(
"Via %s, hole %s" ),
256 msg.Printf(
_(
"Via %s" ),
261 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
270 int id = aEvent.GetId();
328 auto activeToolFunctor =
347 auto canCloseOutline =
367 auto tuningToolActive =
373 auto dimensionToolActive =
401 std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
402 viaSizeMenu->SetTool(
this );
403 m_menu->RegisterSubMenu( viaSizeMenu );
404 ctxMenu.
AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
463 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V, 45" ) );
466 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V" ) );
469 m_frame->DisplayConstraintsMsg( wxString(
"" ) );
490 std::optional<VECTOR2D> startingPoint;
491 std::stack<PCB_SHAPE*> committedLines;
502 while(
drawShape( aEvent, &line, startingPoint, &committedLines ) )
508 std::vector<PCB_CONSTRAINT*> snaps;
516 commit.
Push(
_(
"Draw Line" ) );
519 committedLines.push( line );
523 startingPoint = std::nullopt;
550 std::optional<VECTOR2D> startingPoint;
563 while(
drawShape( aEvent, &rect, startingPoint,
nullptr ) )
567 bool cancelled =
false;
570 cancelled =
m_frame->ShowTextBoxPropertiesDialog( textbox ) != wxID_OK;
581 commit.
Push( isTextBox ?
_(
"Draw Text Box" ) :
_(
"Draw Rectangle" ) );
591 startingPoint = std::nullopt;
629 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
632 std::vector<VECTOR2D> initialPts;
641 initialPts.push_back( aEvent.
Position() );
650 commit.
Add( arc.release() );
652 std::vector<PCB_CONSTRAINT*> snaps;
657 commit.
Push(
_(
"Draw Arc" ) );
663 arc = std::make_unique<PCB_SHAPE>( parent );
685 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
687 std::vector<VECTOR2D> initialPts;
696 initialPts.push_back( aEvent.
Position() );
705 commit.
Add( arc.release() );
707 std::vector<PCB_CONSTRAINT*> snaps;
712 commit.
Push(
_(
"Draw Elliptical Arc" ) );
718 arc = std::make_unique<PCB_SHAPE>( parent );
740 std::unique_ptr<PCB_SHAPE> bezier = std::make_unique<PCB_SHAPE>( parent );
743 std::vector<VECTOR2D> initialPts;
746 bezier->SetFlags(
IS_NEW );
752 initialPts.push_back( aEvent.
Position() );
762 initialPts.push_back( bezier->GetEnd() );
765 if( bezier->GetEnd() != bezier->GetBezierC2() )
767 VECTOR2D mirroredC1 = bezier->GetEnd()
768 - ( bezier->GetBezierC2() - bezier->GetEnd() );
769 initialPts.push_back( mirroredC1 );
772 PCB_SHAPE* committedBezier = bezier.get();
773 commit.
Add( bezier.release() );
775 std::vector<PCB_CONSTRAINT*> snaps;
780 commit.
Push(
_(
"Draw Bezier" ) );
790 bezier = std::make_unique<PCB_SHAPE>( parent );
792 bezier->SetFlags(
IS_NEW );
807 bool immediateMode =
image !=
nullptr;
809 bool ignorePrimePosition =
false;
822 image->SetPosition( cursorPos );
843 m_view->RecacheAllItems();
868 ignorePrimePosition =
true;
877 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
882 m_controls->ForceCursorPosition(
true, cursorPos );
902 else if( evt->IsActivate() )
904 if(
image && evt->IsMoveTool() )
907 evt->SetPassEvent(
false );
913 m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel image creation." ) );
914 evt->SetPassEvent(
false );
918 if( evt->IsMoveTool() )
935 wxFileDialog dlg(
m_frame,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
940 bool cancelled =
false;
945 cancelled = dlg.ShowModal() != wxID_OK;
954 if( evt->IsPrime() && !ignorePrimePosition )
956 cursorPos =
grid.Align( evt->Position() );
967 wxString fullFilename = dlg.GetPath();
969 if( wxFileExists( fullFilename ) )
972 if( !
image || !
image->GetReferenceImage().ReadImageFile( fullFilename ) )
974 wxMessageBox( wxString::Format(
_(
"Could not load image from '%s'." ), fullFilename ) );
985 m_view->RecacheAllItems();
990 m_view->ShowPreview(
true );
995 commit.Push(
_(
"Place Image" ) );
1020 || evt->IsMotion() ) )
1022 image->SetPosition( cursorPos );
1025 m_view->RecacheAllItems();
1038 evt->SetPassEvent();
1058 m_gridHelper( aDrawingTool.GetManager(), aFrame.GetMagneticItemsSettings() )
1064 std::unique_ptr<PCB_POINT> new_point = std::make_unique<PCB_POINT>(
m_frame.GetModel() );
1067 new_point->SetLayer( layer );
1123 bool ignorePrimePosition =
false;
1169 ignorePrimePosition =
true;
1178 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1180 { m_frame->GetActiveLayer() },
GRID_TEXT )
1183 m_controls->ForceCursorPosition(
true, cursorPos );
1189 else if( evt->IsCancelInteractive() || (
text && evt->IsAction( &
ACTIONS::undo ) ) )
1201 else if( evt->IsActivate() )
1206 if( evt->IsMoveTool() )
1224 else if( evt->IsClick(
BUT_LEFT ) )
1226 bool placing =
text !=
nullptr;
1251 text->SetLayer( layer );
1252 text->SetAttributes( textAttrs );
1253 text->SetTextPos( cursorPos );
1271 else if(
text->GetTextPos() != cursorPos )
1280 if( !
m_view->IsLayerVisible(
text->GetLayer() ) )
1282 m_frame->GetAppearancePanel()->SetLayerVisible(
text->GetLayer(),
true );
1283 m_frame->GetCanvas()->Refresh();
1300 commit.
Push(
_(
"Draw Text" ) );
1312 if( evt->IsPrime() && !ignorePrimePosition )
1314 cursorPos = evt->Position();
1315 m_controls->WarpMouseCursor( cursorPos,
true );
1319 m_controls->PinCursorInsideNonAutoscrollArea(
true );
1331 text->SetPosition( cursorPos );
1349 evt->SetPassEvent();
1422 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1424 { m_frame->GetActiveLayer() },
GRID_TEXT )
1427 m_controls->ForceCursorPosition(
true, cursorPos );
1433 else if( evt->IsCancelInteractive() || (
table && evt->IsAction( &
ACTIONS::undo ) ) )
1445 else if( evt->IsActivate() )
1450 if( evt->IsMoveTool() )
1469 else if( evt->IsClick(
BUT_LEFT ) )
1479 table->SetLayer( layer );
1480 table->SetColCount( 1 );
1483 table->SetLayer( layer );
1484 table->SetPosition( cursorPos );
1486 if( !
m_view->IsLayerVisible( layer ) )
1488 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1489 m_frame->GetCanvas()->Refresh();
1521 commit.
Push(
_(
"Draw Table" ) );
1535 VECTOR2I requestedSize( cursorPos - origin );
1537 int colCount = std::max( 1, requestedSize.
x / ( fontSize.
x * 15 ) );
1538 int rowCount = std::max( 1, requestedSize.
y / ( fontSize.
y * 3 ) );
1540 VECTOR2I cellSize( std::max( fontSize.
x * 5, requestedSize.
x / colCount ),
1541 std::max( fontSize.
y * 3, requestedSize.
y / rowCount ) );
1543 cellSize.
x =
KiROUND( (
double) cellSize.
x / gridSize.
x ) * gridSize.
x;
1544 cellSize.
y =
KiROUND( (
double) cellSize.
y / gridSize.
y ) * gridSize.
y;
1546 table->ClearCells();
1547 table->SetColCount( colCount );
1549 for(
int col = 0; col < colCount; ++col )
1550 table->SetColWidth( col, cellSize.
x );
1552 for(
int row = 0; row < rowCount; ++row )
1554 table->SetRowHeight( row, cellSize.
y );
1556 for(
int col = 0; col < colCount; ++col )
1561 table->AddCell( cell );
1582 evt->SetPassEvent();
1657 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1659 { m_frame->GetActiveLayer() },
GRID_TEXT )
1662 m_controls->ForceCursorPosition(
true, cursorPos );
1668 else if( evt->IsCancelInteractive() || ( barcode && evt->IsAction( &
ACTIONS::undo ) ) )
1680 else if( evt->IsActivate() )
1685 if( evt->IsMoveTool() )
1703 else if( evt->IsClick(
BUT_LEFT ) )
1730 if( !
m_view->IsLayerVisible( layer ) )
1732 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1733 m_frame->GetCanvas()->Refresh();
1736 commit.
Add( barcode );
1737 commit.
Push(
_(
"Draw Barcode" ) );
1747 evt->SetPassEvent();
1771 enum DIMENSION_STEPS
1786 int step = SET_ORIGIN;
1799 m_view->Update( &preview );
1806 dimension =
nullptr;
1835 if( step > SET_ORIGIN )
1836 frame()->SetMsgPanel( dimension );
1842 if( evt->Modifier(
MD_CTRL ) )
1845 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1853 grid.SetUseGrid(
false );
1857 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
1861 m_controls->ForceCursorPosition(
true, cursorPos );
1863 if( evt->IsCancelInteractive() || ( dimension && evt->IsAction( &
ACTIONS::undo ) ) )
1867 if( step != SET_ORIGIN )
1877 else if( evt->IsActivate() )
1879 if( step != SET_ORIGIN )
1882 if( evt->IsPointEditor() )
1886 else if( evt->IsMoveTool() )
1901 m_view->Update( &preview );
1902 frame()->SetMsgPanel( dimension );
1910 m_view->Update( &preview );
1911 frame()->SetMsgPanel( dimension );
1932 auto setMeasurementAttributes =
1946 setMeasurementAttributes( dimension );
1951 setMeasurementAttributes( dimension );
1960 setMeasurementAttributes( dimension );
1969 wxFAIL_MSG( wxT(
"Unhandled action in DRAWING_TOOL::DrawDimension" ) );
1972 t = dimension->
Type();
1983 dimension->
SetEnd( cursorPos );
1986 if( !
m_view->IsLayerVisible( layer ) )
1988 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1989 m_frame->GetCanvas()->Refresh();
1992 preview.
Add( dimension );
1993 frame()->SetMsgPanel( dimension );
2019 preview.
Remove( dimension );
2021 commit.
Add( dimension );
2027 commit.
Push(
_(
"Draw Dimension" ) );
2031 frame()->OnEditItemRequest( dimension );
2038 if( ++step >= FINISHED )
2040 dimension =
nullptr;
2045 else if( evt->IsDblClick(
BUT_LEFT ) )
2050 else if( evt->IsMotion() )
2055 dimension->
SetEnd( cursorPos );
2079 textOffset = -textOffset;
2088 textOffset = -textOffset;
2105 double height = (
delta.x * cos( angle ) ) + (
delta.y * sin( angle ) );
2143 ortho->SetHeight( vert ? heightVector.
x : heightVector.
y );
2151 m_view->Update( &preview );
2157 if( !
m_view->IsLayerVisible( layer ) )
2159 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2160 m_frame->GetCanvas()->Refresh();
2170 m_view->Update( &preview );
2171 frame()->SetMsgPanel( dimension );
2175 if( step == SET_END || step == SET_HEIGHT )
2177 frame()->OnEditItemRequest( dimension );
2179 frame()->SetMsgPanel( dimension );
2189 switch( dimension->
Type() )
2204 m_view->Update( &preview );
2213 evt->SetPassEvent();
2217 if( step != SET_ORIGIN )
2225 m_view->Remove( &preview );
2254 if( dlgResult != wxID_OK )
2260 wxMessageBox(
_(
"No graphic items found in file.") );
2266 std::vector<BOARD_ITEM*> newItems;
2267 std::vector<BOARD_ITEM*> selectedItems;
2275 size_t boardItemCount = std::count_if( list.begin(), list.end(),
2276 [](
const std::unique_ptr<EDA_ITEM>& ptr )
2278 return ptr->IsBOARD_ITEM();
2281 if( boardItemCount >= 2 )
2285 newItems.push_back(
group );
2286 selectedItems.push_back(
group );
2293 std::vector<PCB_SHAPE*> shapeList;
2295 for(
const std::unique_ptr<EDA_ITEM>& ptr : list )
2298 shapeList.push_back( shape );
2304 for( std::unique_ptr<EDA_ITEM>& ptr : list )
2306 EDA_ITEM* eda_item = ptr.release();
2312 newItems.push_back( item );
2315 group->AddItem( item );
2317 selectedItems.push_back( item );
2322 preview.
Add( eda_item );
2328 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
2336 commit.
Push(
_(
"Import Graphics" ) );
2344 if( !
m_view->IsLayerVisible( layer ) )
2346 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2347 m_frame->GetCanvas()->Refresh();
2375 item->Move(
delta );
2377 m_view->Update( &preview );
2385 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2390 m_controls->ForceCursorPosition(
true, cursorPos );
2392 if( evt->IsCancelInteractive() || evt->IsActivate() )
2404 else if( evt->IsMotion() )
2409 item->Move(
delta );
2411 m_view->Update( &preview );
2423 commit.
Push(
_(
"Import Graphics" ) );
2433 evt->SetPassEvent();
2438 m_view->Remove( &preview );
2490 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2493 m_controls->ForceCursorPosition(
true, cursorPos );
2503 footprint->MoveAnchorPosition( moveVector );
2505 commit.
Push(
_(
"Move Footprint Anchor" ) );
2516 else if( evt->IsCancelInteractive() || evt->IsActivate() )
2523 evt->SetPassEvent();
2540 const double cosRot = rot.
Cos();
2541 const double sinRot = rot.
Sin();
2543 const double dx = aCursorPos.
x -
center.x;
2544 const double dy = aCursorPos.
y -
center.y;
2545 const double lx = dx * cosRot + dy * sinRot;
2546 const double ly = -dx * sinRot + dy * cosRot;
2549 const double px = a * t.
Cos();
2550 const double py = b * t.
Sin();
2573 if( halfW >= halfH )
2575 majorRadius = std::max( halfW, 1 );
2576 minorRadius = std::max( halfH, 1 );
2581 majorRadius = std::max( halfH, 1 );
2582 minorRadius = std::max( halfW, 1 );
2607 std::optional<VECTOR2D> aStartingPoint,
2608 std::stack<PCB_SHAPE*>* aCommittedGraphics )
2610 SHAPE_T shape = ( *aGraphic )->GetShape();
2653 m_view->Add( &twoPointAsst );
2655 bool started =
false;
2656 bool cancelled =
false;
2657 bool multiPhase =
false;
2659 bool isLocalOriginSet = (
m_frame->GetScreen()->m_LocalOrigin !=
VECTOR2D( 0, 0 ) );
2679 if( !isLocalOriginSet )
2690 if( aStartingPoint )
2691 m_toolMgr->PrimeTool( *aStartingPoint );
2699 m_frame->SetMsgPanel( graphic );
2709 if( evt->Modifier(
MD_CTRL ) )
2716 if( evt->Modifier(
MD_CTRL ) )
2720 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2725 m_controls->ForceCursorPosition(
true, cursorPos );
2727 if( evt->IsCancelInteractive() || ( started && evt->IsAction( &
ACTIONS::undo ) ) )
2734 evt->SetPassEvent(
false );
2741 else if( evt->IsActivate() )
2743 if( evt->IsPointEditor() )
2747 else if( evt->IsMoveTool() )
2786 m_frame->GetCanvas()->Refresh();
2796 frame()->SetMsgPanel( graphic );
2800 evt->SetPassEvent();
2819 if( aStartingPoint )
2821 cursorPos = *aStartingPoint;
2822 aStartingPoint = std::nullopt;
2837 grid.SetSkipPoint( cursorPos );
2840 twoPointMgr.
SetEnd( cursorPos );
2842 if( !isLocalOriginSet )
2843 m_frame->GetScreen()->m_LocalOrigin = cursorPos;
2846 frame()->SetMsgPanel( graphic );
2853 m_frame->GetCanvas()->Refresh();
2863 else if( multiPhase )
2888 m_view->Remove( &twoPointAsst );
2900 commit.
Add( graphic );
2902 std::vector<PCB_CONSTRAINT*> snaps;
2910 commit.
Push(
_(
"Draw Line" ) );
2924 twoPointMgr.
Reset();
2931 else if( evt->IsMotion() )
2957 frame()->SetMsgPanel( graphic );
2961 VECTOR2I clampedCursorPos = cursorPos;
2985 twoPointMgr.
SetEnd( clampedCursorPos );
2991 m_view->Update( &twoPointAsst );
2997 if( aCommittedGraphics && !aCommittedGraphics->empty() )
2999 twoPointMgr.
SetOrigin( aCommittedGraphics->top()->GetStart() );
3000 twoPointMgr.
SetEnd( aCommittedGraphics->top()->GetEnd() );
3001 aCommittedGraphics->pop();
3018 m_view->Update( &twoPointAsst );
3031 frame()->SetMsgPanel( graphic );
3040 frame()->SetMsgPanel( graphic );
3045 frame()->OnEditItemRequest( graphic );
3047 frame()->SetMsgPanel( graphic );
3056 isLocalOriginSet =
true;
3057 evt->SetPassEvent();
3061 if(
frame()->GetUserUnits() != userUnits )
3063 userUnits =
frame()->GetUserUnits();
3064 twoPointAsst.
SetUnits( userUnits );
3065 m_view->Update( &twoPointAsst );
3067 evt->SetPassEvent();
3071 evt->SetPassEvent();
3075 if( !isLocalOriginSet )
3079 m_view->Remove( &twoPointAsst );
3097 const std::vector<VECTOR2D>& aInitialPts )
3138 bool started =
false;
3139 bool cancelled =
false;
3145 for(
const VECTOR2D& pt : aInitialPts )
3148 if( !aInitialPts.empty() )
3162 m_frame->GetCanvas()->Refresh();
3165 preview.
Add( graphic );
3166 frame()->SetMsgPanel( graphic );
3168 m_toolMgr->PrimeTool( aInitialPts.back() );
3177 m_frame->SetMsgPanel( graphic );
3186 if( evt->Modifier(
MD_CTRL ) )
3189 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3194 m_controls->ForceCursorPosition(
true, cursorPos );
3196 if( evt->IsCancelInteractive() )
3203 evt->SetPassEvent(
false );
3215 else if( evt->IsActivate() )
3217 if( evt->IsPointEditor() )
3221 else if( evt->IsMoveTool() )
3236 else if( evt->IsClick(
BUT_LEFT ) )
3252 m_frame->GetCanvas()->Refresh();
3255 preview.
Add( graphic );
3256 frame()->SetMsgPanel( graphic );
3269 else if( evt->IsMotion() )
3292 m_frame->GetCanvas()->Refresh();
3297 m_view->Update( &preview );
3298 frame()->SetMsgPanel( graphic );
3302 evt->SetPassEvent();
3309 frame()->OnEditItemRequest( graphic );
3310 m_view->Update( &preview );
3311 frame()->SetMsgPanel( graphic );
3316 evt->SetPassEvent();
3333 m_view->Update( &preview );
3334 frame()->SetMsgPanel( graphic );
3346 m_view->Update( &preview );
3347 frame()->SetMsgPanel( graphic );
3359 evt->SetPassEvent();
3368 evt->SetPassEvent();
3378 m_view->Update( &preview );
3383 frame()->SetMsgPanel( graphic );
3389 preview.
Remove( graphic );
3391 m_view->Remove( &preview );
3412 bool clearSelection =
false;
3424 clearSelection =
true;
3435 if( clearSelection )
3471 ZONE* sourceZone =
nullptr;
3483 params.
m_mode = zoneMode;
3494 bool started =
false;
3508 polyGeomMgr.
Reset();
3510 grid.ClearSkipPoint();
3539 if( evt->Modifier(
MD_CTRL ) )
3542 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3544 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
3548 m_controls->ForceCursorPosition(
true, cursorPos );
3552 if( evt->IsCancelInteractive() )
3563 evt->SetPassEvent(
false );
3567 else if( evt->IsActivate() )
3572 if( evt->IsPointEditor() )
3576 else if( evt->IsMoveTool() )
3594 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
3595 m_frame->GetCanvas()->Refresh();
3611 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
3618 polyGeomMgr.
Reset();
3625 else if( polyGeomMgr.
AddPoint( cursorPos ) )
3636 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
3637 m_frame->GetCanvas()->Refresh();
3652 cursorPos = last.value();
3654 m_controls->ForceCursorPosition(
true, cursorPos );
3662 else if( started && ( evt->IsMotion()
3688 evt->SetPassEvent();
3715 std::shared_ptr<DRC_ENGINE> m_drcEngine;
3717 int m_worstClearance;
3718 bool m_allowDRCViolations;
3720 int sub_e(
int aClearance )
3722 return std::max( 0, aClearance - m_drcEpsilon );
3730 m_worstClearance( 0 )
3748 m_worstClearance = std::max( m_worstClearance, constraint.
GetValue().
Min() );
3754 std::optional<int> padOverride =
pad->GetClearanceOverrides(
nullptr );
3756 if( padOverride.has_value() )
3757 m_worstClearance = std::max( m_worstClearance, padOverride.value() );
3766 virtual ~VIA_PLACER()
3784 const BOX2I bbox = getEffectiveBoundingBox( *aVia, aPosition );
3786 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3788 std::vector<PCB_TRACK*> possible_tracks;
3790 wxCHECK(
view,
nullptr );
3792 view->Query( bbox, items );
3796 if( !it.first->IsBOARD_ITEM() )
3811 possible_tracks.push_back( track );
3819 possible_tracks.push_back( arc );
3824 int min_d = std::numeric_limits<int>::max();
3826 for(
PCB_TRACK* track : possible_tracks )
3828 SEG test( track->GetStart(), track->GetEnd() );
3829 int dist = (
test.NearestPoint( aPosition ) - aPosition ).EuclideanNorm();
3834 return_track = track;
3838 return return_track;
3846 ZONE* zone =
dynamic_cast<ZONE*
>( aOther );
3874 int connectedItemNet = connectedItem->
GetNetCode();
3876 if( connectedItemNet == 0 || connectedItemNet == aVia->
GetNetCode() )
3894 if( viaShape->Collide( otherShape.get(), sub_e(
clearance ) ) )
3916 bool checkDRCViolation(
PCB_VIA* aVia )
3918 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3919 std::set<BOARD_ITEM*> checkedItems;
3922 bbox.
Inflate( m_worstClearance );
3923 m_frame->GetCanvas()->GetView()->Query( bbox, items );
3925 for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
3927 if( !it.first->IsBOARD_ITEM() )
3945 else if( checkedItems.count( item ) )
3950 if( hasDRCViolation( aVia, item ) )
3953 checkedItems.insert( item );
3968 const BOX2I bbox = getEffectiveBoundingBox( *aVia, aPosition );
3971 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3973 view.Query( bbox, items );
3977 if( !it.first->IsBOARD_ITEM() )
3986 if(
pad.HitTest( aPosition ) )
3997 BOX2I bbox = getEffectiveBoundingBox( *aVia, aPosition );
3999 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4002 std::vector<PCB_SHAPE*> possible_shapes;
4004 view->Query( bbox, items );
4008 if( !it.first->IsBOARD_ITEM() )
4021 possible_shapes.push_back( shape );
4026 int min_d = std::numeric_limits<int>::max();
4028 for(
PCB_SHAPE* shape : possible_shapes )
4030 int dist = ( shape->GetPosition() - aPosition ).EuclideanNorm();
4035 return_shape = shape;
4039 return return_shape;
4042 std::optional<int> selectPossibleNetsByPopupMenu( std::set<int>& aNetcodeList )
4046 std::map<int, int> menuIDNetCodeMap;
4049 for(
int netcode : aNetcodeList )
4055 menuText = wxString::Format(
"%s\t",
4058 menuText = wxString::Format(
"&%d %s\t",
4069 menuIDNetCodeMap[ menuID ] = netcode;
4079 int selectedNetCode = -1;
4080 bool cancelled =
false;
4086 evt->SetPassEvent();
4090 std::optional<int>
id = evt->GetCommandId();
4093 if(
id && ( *
id > 0 ) && ( *
id < menuID ) )
4095 selectedNetCode = menuIDNetCodeMap.at( *
id );
4110 return std::optional<int>();
4112 return selectedNetCode;
4115 std::optional<int> findStitchedZoneNet(
PCB_VIA* aVia )
4119 std::set<int> netcodeList;
4129 if( z->IsOnLayer(
m_frame->GetActiveLayer() ) )
4131 if( z->HitTestFilledArea(
m_frame->GetActiveLayer(), position ) )
4132 netcodeList.insert( z->GetNetCode() );
4139 if( netcodeList.size() == 1 )
4140 return *netcodeList.begin();
4147 if( z->GetIsRuleArea() )
4152 if( z->IsOnLayer( layer ) )
4154 if( z->HitTestFilledArea( layer, position ) )
4155 netcodeList.insert( z->GetNetCode() );
4161 if( netcodeList.size() == 1 )
4162 return *netcodeList.begin();
4164 if( netcodeList.size() > 1 )
4167 return selectPossibleNetsByPopupMenu( netcodeList );
4192 SEG trackSeg( track->GetStart(), track->GetEnd() );
4202 if(
PAD*
pad = findPad(
via, position ) )
4213 if( shape->IsAnyFill() )
4219 double shapeArea = poly.
Area();
4221 int R =
via->GetWidth( shape->GetLayer() ) / 2;
4222 double viaArea =
M_PI * R * R;
4224 if( viaArea * 4 > shapeArea )
4229 switch( shape->GetShape() )
4233 SEG seg( shape->GetStart(), shape->GetEnd() );
4241 if( ( shape->GetEnd() - position ).SquaredEuclideanNorm() <
4242 ( shape->GetStart() - position ).SquaredEuclideanNorm() )
4256 if( !shape->IsPolyShapeValid() )
4263 std::optional<SEG> nearestSeg;
4264 int minDist = std::numeric_limits<int>::max();
4273 int dist = seg.
Distance( position );
4275 if( dist < minDist )
4314 via->SetIsFree(
false );
4318 via->SetNetCode(
pad->GetNetCode() );
4319 via->SetIsFree(
false );
4324 via->SetIsFree(
false );
4328 std::optional<int> netcode = findStitchedZoneNet(
via );
4330 if( !netcode.has_value() )
4333 via->SetNetCode( netcode.value() );
4334 via->SetIsFree(
via->GetNetCode() > 0 );
4337 if( checkDRCViolation(
via ) )
4339 m_frame->ShowInfoBarError(
_(
"Via location violates DRC." ),
true,
4340 WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
4342 if( !m_allowDRCViolations )
4347 if( infobar->
GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION )
4356 if( track && m_gridHelper.
GetSnap() )
4360 SEG trackSeg( trackStart, trackEnd );
4362 if( viaPos == trackStart || viaPos == trackEnd )
4376 newTrack->
SetEnd( trackEnd );
4377 aCommit.
Add( newTrack );
4383 std::unique_ptr<BOARD_ITEM> CreateItem()
override
4388 via->SetNetCode( 0 );
4401 if( first_layer !=
m_frame->GetScreen()->m_Route_Layer_TOP )
4402 last_layer =
m_frame->GetScreen()->m_Route_Layer_TOP;
4404 last_layer =
m_frame->GetScreen()->m_Route_Layer_BOTTOM;
4406 via->SetLayerPair( first_layer, last_layer );
4412 via->GetEffectiveNetClass()->GetuViaDiameter() );
4413 via->SetDrill(
via->GetEffectiveNetClass()->GetuViaDrill() );
4421 return std::unique_ptr<BOARD_ITEM>(
via );
4425 VIA_PLACER placer(
frame() );
4450 std::optional<VECTOR2D> startingPoint;
4452 auto makeShape = [&]()
4469 while( aDrawer( aEvent, &shape, startingPoint ) )
4473 commit.
Add( shape );
4475 std::vector<PCB_CONSTRAINT*> snaps;
4480 commit.
Push( aCommitLabel );
4485 shape = makeShape();
4486 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 activatePointEditor
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION refreshPreview
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 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.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
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
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)
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.
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
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
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
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 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 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 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()
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.
The main frame for Pcbnew.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
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
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
const PADSTACK & Padstack() const
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().
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.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
bool GetDoNotAllowVias() const
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::vector< ENDPOINT_BINDING > SelectEndpointBindings(BOARD *aBoard, const KIID &aItem, const VECTOR2I &aStart, const std::optional< VECTOR2I > &aEnd, double aMaxDist)
Choose the coincident bindings a freshly drawn item endpoints should take so it tracks the geometry i...
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.
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.
void InferBold(TEXT_ATTRIBUTES *aAttrs)
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).
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
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.
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.