24#include "dialog_table_properties.h"
64#include <wx/filedlg.h>
109 if( !aBoard || !aDimension )
120 aDimension->
GetEnd(), tol );
128 auto constraint = std::make_unique<PCB_CONSTRAINT>( aParent, aType );
129 constraint->AddMember( aDimension->
m_Uuid, aDimAnchor );
130 constraint->AddMember( *arc, aTargetAnchor );
133 aCommit.
Add( constraint.release() );
142 std::optional<VECTOR2I>
end;
144 switch( aDimension->
Type() )
155 std::vector<ENDPOINT_BINDING> bindings =
161 constraint->AddMember( aDimension->
m_Uuid, binding.sourceAnchor );
162 constraint->AddMember( binding.target.m_item, binding.target.m_anchor, binding.target.m_index );
167 aCommit.
Add( constraint.release() );
177 std::vector<PCB_CONSTRAINT*> snaps;
182 aCommit.
Add( entry.constraint.release() );
184 if( entry.needsSolve )
185 snaps.push_back( added );
195 const std::vector<PCB_CONSTRAINT*>& aConstraints )
197 if( aConstraints.empty() )
211 if( !commit.
Empty() )
242 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
251 if(
via.m_Drill > 0 )
253 msg.Printf(
_(
"Via %s, hole %s" ),
259 msg.Printf(
_(
"Via %s" ),
264 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
273 int id = aEvent.GetId();
331 auto activeToolFunctor =
351 auto canCloseOutline =
366 auto canFinishShape =
380 auto tuningToolActive =
386 auto dimensionToolActive =
421 std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
422 viaSizeMenu->SetTool(
this );
423 m_menu->RegisterSubMenu( viaSizeMenu );
424 ctxMenu.
AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
482 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V, 45" ) );
485 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V" ) );
488 m_frame->DisplayConstraintsMsg( wxString(
"" ) );
509 std::optional<VECTOR2D> startingPoint;
510 std::stack<PCB_SHAPE*> committedLines;
523 while(
drawShape( originalEvent, &line, startingPoint, &committedLines ) )
529 std::vector<PCB_CONSTRAINT*> snaps;
537 commit.
Push(
_(
"Draw Line" ) );
540 committedLines.push( line );
544 startingPoint = std::nullopt;
571 std::optional<VECTOR2D> startingPoint;
586 while(
drawShape( originalEvent, &rect, startingPoint,
nullptr ) )
590 bool cancelled =
false;
593 cancelled =
m_frame->ShowTextBoxPropertiesDialog( textbox ) != wxID_OK;
604 commit.
Push( isTextBox ?
_(
"Draw Text Box" ) :
_(
"Draw Rectangle" ) );
614 startingPoint = std::nullopt;
652 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
655 std::vector<VECTOR2D> initialPts;
674 std::optional<ARC_TANGENT_SEED> tangentSeed;
693 commit.
Add( arc.release() );
695 std::vector<PCB_CONSTRAINT*> snaps;
700 commit.
Push(
_(
"Draw Arc" ) );
706 arc = std::make_unique<PCB_SHAPE>( parent );
728 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
731 std::vector<VECTOR2D> initialPts;
755 commit.
Add( arc.release() );
757 std::vector<PCB_CONSTRAINT*> snaps;
762 commit.
Push(
_(
"Draw Elliptical Arc" ) );
768 arc = std::make_unique<PCB_SHAPE>( parent );
790 std::unique_ptr<PCB_SHAPE> bezier = std::make_unique<PCB_SHAPE>( parent );
793 std::vector<VECTOR2D> initialPts;
796 bezier->SetFlags(
IS_NEW );
818 initialPts.push_back( bezier->GetEnd() );
821 if( bezier->GetEnd() != bezier->GetBezierC2() )
823 VECTOR2D mirroredC1 = bezier->GetEnd()
824 - ( bezier->GetBezierC2() - bezier->GetEnd() );
825 initialPts.push_back( mirroredC1 );
828 PCB_SHAPE* committedBezier = bezier.get();
829 commit.
Add( bezier.release() );
831 std::vector<PCB_CONSTRAINT*> snaps;
836 commit.
Push(
_(
"Draw Bezier" ) );
846 bezier = std::make_unique<PCB_SHAPE>( parent );
848 bezier->SetFlags(
IS_NEW );
863 bool immediateMode =
image !=
nullptr;
865 bool ignorePrimePosition =
false;
881 image->SetPosition( cursorPos );
900 m_view->RecacheAllItems();
925 ignorePrimePosition =
true;
934 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
938 const LSET snapLayers = {
m_frame->GetActiveLayer() };
942 m_controls->ForceCursorPosition(
true, cursorPos );
954 else if( evt->IsActivate() )
956 if(
image && evt->IsMoveTool() )
959 evt->SetPassEvent(
false );
965 m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel image creation." ) );
966 evt->SetPassEvent(
false );
970 if( evt->IsMoveTool() )
973 m_frame->PushTool( originalEvent );
985 wxFileDialog dlg(
m_frame,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
990 bool cancelled =
false;
995 cancelled = dlg.ShowModal() != wxID_OK;
1004 if( evt->IsPrime() && !ignorePrimePosition )
1006 cursorPos =
grid.Align( evt->Position() );
1017 wxString fullFilename = dlg.GetPath();
1019 if( wxFileExists( fullFilename ) )
1022 if( !
image || !
image->GetReferenceImage().ReadImageFile( fullFilename ) )
1024 wxMessageBox( wxString::Format(
_(
"Could not load image from '%s'." ), fullFilename ) );
1035 m_view->RecacheAllItems();
1040 m_view->ShowPreview(
true );
1044 commit.Add(
image );
1045 commit.Push(
_(
"Place Image" ) );
1067 || evt->IsMotion() ) )
1069 image->SetPosition( cursorPos );
1072 m_view->RecacheAllItems();
1085 evt->SetPassEvent();
1105 m_gridHelper( aDrawingTool.GetManager(), aFrame.GetMagneticItemsSettings() )
1111 std::unique_ptr<PCB_POINT> new_point = std::make_unique<PCB_POINT>(
m_frame.GetModel() );
1114 new_point->SetLayer( layer );
1169 bool ignorePrimePosition =
false;
1216 ignorePrimePosition =
true;
1225 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1229 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1232 m_controls->ForceCursorPosition(
true, cursorPos );
1238 else if( evt->IsCancelInteractive() || (
text && evt->IsAction( &
ACTIONS::undo ) ) )
1245 else if( evt->IsActivate() )
1250 if( evt->IsMoveTool() )
1253 m_frame->PushTool( originalEvent );
1267 bool placing =
text !=
nullptr;
1291 text->SetLayer( layer );
1292 text->SetAttributes( textAttrs );
1293 text->SetTextPos( cursorPos );
1311 else if(
text->GetTextPos() != cursorPos )
1320 if( !
m_view->IsLayerVisible(
text->GetLayer() ) )
1322 m_frame->GetAppearancePanel()->SetLayerVisible(
text->GetLayer(),
true );
1323 m_frame->GetCanvas()->Refresh();
1340 commit.
Push(
_(
"Draw Text" ) );
1352 if( evt->IsPrime() && !ignorePrimePosition )
1354 cursorPos = evt->Position();
1355 m_controls->WarpMouseCursor( cursorPos,
true );
1359 m_controls->PinCursorInsideNonAutoscrollArea(
true );
1371 text->SetPosition( cursorPos );
1388 evt->SetPassEvent();
1463 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1467 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1470 m_controls->ForceCursorPosition(
true, cursorPos );
1476 else if( evt->IsCancelInteractive() || (
table && evt->IsAction( &
ACTIONS::undo ) ) )
1483 else if( evt->IsActivate() )
1488 if( evt->IsMoveTool() )
1491 m_frame->PushTool( originalEvent );
1514 table->SetLayer( layer );
1515 table->SetColCount( 1 );
1518 table->SetLayer( layer );
1519 table->SetPosition( cursorPos );
1521 if( !
m_view->IsLayerVisible( layer ) )
1523 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1524 m_frame->GetCanvas()->Refresh();
1556 commit.
Push(
_(
"Draw Table" ) );
1570 VECTOR2I requestedSize( cursorPos - origin );
1572 int colCount = std::max( 1, requestedSize.
x / ( fontSize.
x * 15 ) );
1573 int rowCount = std::max( 1, requestedSize.
y / ( fontSize.
y * 3 ) );
1575 VECTOR2I cellSize( std::max( fontSize.
x * 5, requestedSize.
x / colCount ),
1576 std::max( fontSize.
y * 3, requestedSize.
y / rowCount ) );
1578 cellSize.
x =
KiROUND( (
double) cellSize.
x / gridSize.
x ) * gridSize.
x;
1579 cellSize.
y =
KiROUND( (
double) cellSize.
y / gridSize.
y ) * gridSize.
y;
1581 table->ClearCells();
1582 table->SetColCount( colCount );
1584 for(
int col = 0; col < colCount; ++col )
1585 table->SetColWidth( col, cellSize.
x );
1587 for(
int row = 0; row < rowCount; ++row )
1589 table->SetRowHeight( row, cellSize.
y );
1591 for(
int col = 0; col < colCount; ++col )
1596 table->AddCell( cell );
1617 evt->SetPassEvent();
1693 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1697 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1700 m_controls->ForceCursorPosition(
true, cursorPos );
1706 else if( evt->IsCancelInteractive() || ( barcode && evt->IsAction( &
ACTIONS::undo ) ) )
1713 else if( evt->IsActivate() )
1718 if( evt->IsMoveTool() )
1721 m_frame->PushTool( originalEvent );
1760 if( !
m_view->IsLayerVisible( layer ) )
1762 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1763 m_frame->GetCanvas()->Refresh();
1766 commit.
Add( barcode );
1767 commit.
Push(
_(
"Draw Barcode" ) );
1777 evt->SetPassEvent();
1801 enum DIMENSION_STEPS
1815 int step = SET_ORIGIN;
1828 m_view->Update( &preview );
1835 dimension =
nullptr;
1865 if( step > SET_ORIGIN )
1866 frame()->SetMsgPanel( dimension );
1873 if( evt->Modifier(
MD_CTRL ) )
1877 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1885 grid.SetUseGrid(
false );
1889 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
1892 m_controls->ForceCursorPosition(
true, cursorPos );
1894 if( evt->IsCancelInteractive() || ( dimension && evt->IsAction( &
ACTIONS::undo ) ) )
1898 if( step != SET_ORIGIN )
1903 else if( evt->IsActivate() )
1905 if( step != SET_ORIGIN )
1908 if( evt->IsPointEditor() )
1914 if( evt->IsMoveTool() )
1917 m_frame->PushTool( originalEvent );
1926 m_view->Update( &preview );
1927 frame()->SetMsgPanel( dimension );
1935 m_view->Update( &preview );
1936 frame()->SetMsgPanel( dimension );
1958 auto setMeasurementAttributes =
1972 setMeasurementAttributes( dimension );
1977 setMeasurementAttributes( dimension );
1986 setMeasurementAttributes( dimension );
1995 wxFAIL_MSG( wxT(
"Unhandled action in DRAWING_TOOL::DrawDimension" ) );
1998 t = dimension->
Type();
2009 dimension->
SetEnd( cursorPos );
2012 if( !
m_view->IsLayerVisible( layer ) )
2014 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2015 m_frame->GetCanvas()->Refresh();
2018 preview.
Add( dimension );
2019 frame()->SetMsgPanel( dimension );
2045 preview.
Remove( dimension );
2047 commit.
Add( dimension );
2053 commit.
Push(
_(
"Draw Dimension" ) );
2057 frame()->OnEditItemRequest( dimension );
2066 dimension =
nullptr;
2081 dimension->
SetEnd( cursorPos );
2105 textOffset = -textOffset;
2114 textOffset = -textOffset;
2131 double height = (
delta.x * cos( angle ) ) + (
delta.y * sin( angle ) );
2169 ortho->SetHeight( vert ? heightVector.
x : heightVector.
y );
2177 m_view->Update( &preview );
2183 if( !
m_view->IsLayerVisible( layer ) )
2185 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2186 m_frame->GetCanvas()->Refresh();
2196 m_view->Update( &preview );
2197 frame()->SetMsgPanel( dimension );
2201 if( step == SET_END || step == SET_HEIGHT )
2203 frame()->OnEditItemRequest( dimension );
2205 frame()->SetMsgPanel( dimension );
2215 switch( dimension->
Type() )
2230 m_view->Update( &preview );
2239 evt->SetPassEvent();
2243 if( step != SET_ORIGIN )
2251 m_view->Remove( &preview );
2280 if( dlgResult != wxID_OK )
2286 wxMessageBox(
_(
"No graphic items found in file.") );
2292 std::vector<BOARD_ITEM*> newItems;
2293 std::vector<BOARD_ITEM*> selectedItems;
2301 size_t boardItemCount = std::count_if( list.begin(), list.end(),
2302 [](
const std::unique_ptr<EDA_ITEM>& ptr )
2304 return ptr->IsBOARD_ITEM();
2307 if( boardItemCount >= 2 )
2311 newItems.push_back(
group );
2312 selectedItems.push_back(
group );
2319 std::vector<PCB_SHAPE*> shapeList;
2321 for(
const std::unique_ptr<EDA_ITEM>& ptr : list )
2324 shapeList.push_back( shape );
2330 for( std::unique_ptr<EDA_ITEM>& ptr : list )
2332 EDA_ITEM* eda_item = ptr.release();
2338 newItems.push_back( item );
2341 group->AddItem( item );
2343 selectedItems.push_back( item );
2348 preview.
Add( eda_item );
2354 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
2362 commit.
Push(
_(
"Import Graphics" ) );
2370 if( !
m_view->IsLayerVisible( layer ) )
2372 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2373 m_frame->GetCanvas()->Refresh();
2401 item->Move(
delta );
2403 m_view->Update( &preview );
2411 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2414 m_controls->ForceCursorPosition(
true, cursorPos );
2416 if( evt->IsCancelInteractive() || evt->IsActivate() )
2433 item->Move(
delta );
2435 m_view->Update( &preview );
2448 commit.
Push(
_(
"Import Graphics" ) );
2458 evt->SetPassEvent();
2463 m_view->Remove( &preview );
2513 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2515 m_controls->ForceCursorPosition(
true, cursorPos );
2526 footprint->MoveAnchorPosition( moveVector );
2528 commit.
Push(
_(
"Move Footprint Anchor" ) );
2537 else if( evt->IsCancelInteractive() || evt->IsActivate() )
2543 evt->SetPassEvent();
2572 int step = SET_CENTER;
2615 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2617 m_controls->ForceCursorPosition(
true, cursorPos );
2622 if( step == SET_CENTER )
2631 board->Add( griditem );
2638 sizeToCursor( cursorPos );
2643 board->Remove( griditem );
2646 commit.
Add( griditem );
2647 commit.
Push(
_(
"Place Sub-grid" ) );
2657 else if( evt->IsCancelInteractive() || evt->IsActivate() || ( griditem && evt->IsAction( &
ACTIONS::undo ) ) )
2659 bool restart = griditem && !evt->IsActivate();
2664 board->Remove( griditem );
2674 else if( griditem && ( evt->IsMotion()
2677 sizeToCursor( cursorPos );
2682 evt->SetPassEvent();
2699 const double cosRot = rot.
Cos();
2700 const double sinRot = rot.
Sin();
2702 const double dx = aCursorPos.
x -
center.x;
2703 const double dy = aCursorPos.
y -
center.y;
2704 const double lx = dx * cosRot + dy * sinRot;
2705 const double ly = -dx * sinRot + dy * cosRot;
2708 const double px = a * t.
Cos();
2709 const double py = b * t.
Sin();
2732 if( halfW >= halfH )
2734 majorRadius = std::max( halfW, 1 );
2735 minorRadius = std::max( halfH, 1 );
2740 majorRadius = std::max( halfH, 1 );
2741 minorRadius = std::max( halfW, 1 );
2766 std::stack<PCB_SHAPE*>* aCommittedGraphics )
2768 SHAPE_T shape = ( *aGraphic )->GetShape();
2810 m_view->Add( &twoPointAsst );
2812 bool started =
false;
2813 bool cancelled =
false;
2814 bool multiPhase =
false;
2816 bool isLocalOriginSet = (
m_frame->GetScreen()->m_LocalOrigin !=
VECTOR2D( 0, 0 ) );
2836 if( !isLocalOriginSet )
2847 if( aStartingPoint )
2848 m_toolMgr->PrimeTool( *aStartingPoint );
2856 m_frame->SetMsgPanel( graphic );
2868 if( evt->Modifier(
MD_CTRL ) )
2876 if( evt->Modifier(
MD_CTRL ) )
2880 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2884 m_controls->ForceCursorPosition(
true, cursorPos );
2886 if( evt->IsCancelInteractive() || ( started && evt->IsAction( &
ACTIONS::undo ) ) )
2893 evt->SetPassEvent(
false );
2899 else if( evt->IsActivate() )
2901 if( evt->IsPointEditor() )
2907 if( evt->IsMoveTool() )
2940 m_frame->GetCanvas()->Refresh();
2950 frame()->SetMsgPanel( graphic );
2954 evt->SetPassEvent();
2974 if( aStartingPoint )
2976 cursorPos = *aStartingPoint;
2977 aStartingPoint = std::nullopt;
2992 grid.SetSkipPoint( cursorPos );
2995 twoPointMgr.
SetEnd( cursorPos );
2997 if( !isLocalOriginSet )
2998 m_frame->GetScreen()->m_LocalOrigin = cursorPos;
3001 frame()->SetMsgPanel( graphic );
3008 m_frame->GetCanvas()->Refresh();
3018 else if( multiPhase )
3043 m_view->Remove( &twoPointAsst );
3055 commit.
Add( graphic );
3057 std::vector<PCB_CONSTRAINT*> snaps;
3065 commit.
Push(
_(
"Draw Line" ) );
3071 else if( twoPointMgr.
IsEmpty()
3081 twoPointMgr.
Reset();
3114 frame()->SetMsgPanel( graphic );
3118 VECTOR2I clampedCursorPos = cursorPos;
3142 twoPointMgr.
SetEnd( clampedCursorPos );
3148 m_view->Update( &twoPointAsst );
3154 if( aCommittedGraphics && !aCommittedGraphics->empty() )
3156 twoPointMgr.
SetOrigin( aCommittedGraphics->top()->GetStart() );
3157 twoPointMgr.
SetEnd( aCommittedGraphics->top()->GetEnd() );
3158 aCommittedGraphics->pop();
3175 m_view->Update( &twoPointAsst );
3188 frame()->SetMsgPanel( graphic );
3197 frame()->SetMsgPanel( graphic );
3202 frame()->OnEditItemRequest( graphic );
3204 frame()->SetMsgPanel( graphic );
3213 isLocalOriginSet =
true;
3214 evt->SetPassEvent();
3218 if(
frame()->GetUserUnits() != userUnits )
3220 userUnits =
frame()->GetUserUnits();
3221 twoPointAsst.
SetUnits( userUnits );
3222 m_view->Update( &twoPointAsst );
3224 evt->SetPassEvent();
3228 evt->SetPassEvent();
3232 if( !isLocalOriginSet )
3236 m_view->Remove( &twoPointAsst );
3255 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() );
3265 const std::vector<VECTOR2D>& aInitialPts,
3266 const std::optional<ARC_TANGENT_SEED>& aTangentSeed,
3304 auto findTangentSeed =
3305 [&](
const VECTOR2I&,
const VECTOR2I& aPos ) -> std::optional<ARC_TANGENT_SEED>
3310 [&](
const PCB_SHAPE* aShape ) -> std::optional<ARC_TANGENT_SEED>
3312 if( !aShape || aShape->GetLayer() !=
m_layer )
3313 return std::nullopt;
3315 BOX2I reach = aShape->GetBoundingBox();
3318 return std::nullopt;
3323 if( std::optional<ARC_TANGENT_SEED> seed = seedFrom(
dynamic_cast<PCB_SHAPE*
>(
grid.GetSnapped() ) ) )
3328 if( std::optional<ARC_TANGENT_SEED> seed = seedFrom( shape ) )
3332 return std::nullopt;
3338 m_frame->SelectToolbarAction( PCB_ACTIONS::DrawArcForMode( aMode ) );
3339 m_toolMgr->PostAction( ACTIONS::refreshPreview );
3347 bool started =
false;
3348 bool cancelled =
false;
3349 bool finished =
false;
3355 for(
const VECTOR2D& pt : aInitialPts )
3358 if( !aInitialPts.empty() || aTangentSeed )
3372 m_frame->GetCanvas()->Refresh();
3375 preview.
Add( graphic );
3376 frame()->SetMsgPanel( graphic );
3385 m_frame->SetMsgPanel( graphic );
3394 if( evt->Modifier(
MD_CTRL ) )
3397 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3400 m_controls->ForceCursorPosition(
true, cursorPos );
3402 if( evt->IsCancelInteractive() )
3409 evt->SetPassEvent(
false );
3424 else if( evt->IsActivate() )
3426 if( evt->IsPointEditor() )
3432 if( evt->IsMoveTool() )
3458 m_frame->GetCanvas()->Refresh();
3461 preview.
Add( graphic );
3462 frame()->SetMsgPanel( graphic );
3466 arcSession.
PlacePoint( cursorPos, cursorPos );
3469 *aLastClick = cursorPos;
3471 else if( evt->IsDblClick(
BUT_LEFT )
3514 m_frame->GetCanvas()->Refresh();
3519 m_view->Update( &preview );
3520 frame()->SetMsgPanel( graphic );
3524 evt->SetPassEvent();
3531 frame()->OnEditItemRequest( graphic );
3532 m_view->Update( &preview );
3533 frame()->SetMsgPanel( graphic );
3538 evt->SetPassEvent();
3555 m_view->Update( &preview );
3556 frame()->SetMsgPanel( graphic );
3568 m_view->Update( &preview );
3569 frame()->SetMsgPanel( graphic );
3581 evt->SetPassEvent();
3590 evt->SetPassEvent();
3600 m_view->Update( &preview );
3605 frame()->SetMsgPanel( graphic );
3611 preview.
Remove( graphic );
3613 m_view->Remove( &preview );
3635 bool clearSelection =
false;
3647 clearSelection =
true;
3658 if( clearSelection )
3697 ZONE* sourceZone =
nullptr;
3709 params.
m_mode = zoneMode;
3720 bool started =
false;
3734 polyGeomMgr.
Reset();
3736 grid.ClearSkipPoint();
3765 if( evt->Modifier(
MD_CTRL ) )
3768 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3770 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
3773 m_controls->ForceCursorPosition(
true, cursorPos );
3777 if( evt->IsCancelInteractive() )
3786 evt->SetPassEvent(
false );
3790 else if( evt->IsActivate() )
3795 if( evt->IsPointEditor() )
3801 if( evt->IsMoveTool() )
3804 m_frame->PushTool( originalEvent );
3816 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
3817 m_frame->GetCanvas()->Refresh();
3835 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
3843 polyGeomMgr.
Reset();
3849 else if( polyGeomMgr.
AddPoint( cursorPos ) )
3860 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
3861 m_frame->GetCanvas()->Refresh();
3876 cursorPos = last.value();
3878 m_controls->ForceCursorPosition(
true, cursorPos );
3886 else if( started && ( evt->IsMotion()
3913 evt->SetPassEvent();
3941 worst = std::max( worst, constraint.
GetValue().
Min() );
3945 for(
PAD*
pad : footprint->Pads() )
3947 std::optional<int> padOverride =
pad->GetClearanceOverrides(
nullptr );
3949 if( padOverride.has_value() )
3950 worst = std::max( worst, padOverride.value() );
3964 auto sub_e = [&](
int aClearance )
3966 return std::max( 0, aClearance - aEpsilon );
3972 ZONE* zone =
dynamic_cast<ZONE*
>( aOther );
3986 zoneOutline = zone->
Outline();
3999 if( zoneOutline->
Collide(
via->GetPosition(),
via->GetWidth( layer ) / 2 ) )
4012 bool skipCopper =
false;
4016 int connectedItemNet = connectedItem->
GetNetCode();
4018 if( connectedItemNet != 0 && connectedItemNet == aItem->
GetNetCode() )
4022 if( connectedItemNet == 0 )
4042 if( itemShape->Collide( otherShape.get(), sub_e(
clearance ) ) )
4067 int aWorstClearance,
int aEpsilon )
4069 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4070 std::set<BOARD_ITEM*> checkedItems;
4073 bbox.
Inflate( aWorstClearance );
4076 for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
4078 if( !it.first->IsBOARD_ITEM() )
4096 else if( checkedItems.count( item ) )
4104 checkedItems.insert( item );
4140 const LSET& aLayers,
int aSnapRange )
4142 const LSET lset = aLayers;
4145 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4147 std::vector<PCB_TRACK*> possible_tracks;
4149 wxCHECK( view,
nullptr );
4151 view->
Query( bbox, items );
4155 if( !it.first->IsBOARD_ITEM() )
4171 possible_tracks.push_back( track );
4179 possible_tracks.push_back( arc );
4184 int min_d = std::numeric_limits<int>::max();
4186 for(
PCB_TRACK* track : possible_tracks )
4188 SEG test( track->GetStart(), track->GetEnd() );
4189 int dist = (
test.NearestPoint( aPosition ) - aPosition ).EuclideanNorm();
4194 return_track = track;
4198 return return_track;
4205 const LSET lset = aLayers;
4209 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4211 view.
Query( bbox, items );
4215 if( !it.first->IsBOARD_ITEM() )
4224 if(
pad.HitTest( aPosition, aSnapRange ) )
4234 const LSET& aLayers,
int aSnapRange = 0 )
4239 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4242 std::vector<PCB_SHAPE*> possible_shapes;
4244 view->
Query( bbox, items );
4248 if( !it.first->IsBOARD_ITEM() )
4260 if( shape->
HitTest( aPosition, std::max( aVia->
GetWidth( activeLayer ) / 2, aSnapRange ) ) )
4261 possible_shapes.push_back( shape );
4266 int min_d = std::numeric_limits<int>::max();
4268 for(
PCB_SHAPE* shape : possible_shapes )
4270 int dist = ( shape->GetPosition() - aPosition ).EuclideanNorm();
4275 return_shape = shape;
4279 return return_shape;
4297 std::shared_ptr<DRC_ENGINE> m_drcEngine;
4299 int m_worstClearance;
4300 bool m_allowDRCViolations;
4302 int sub_e(
int aClearance )
4304 return std::max( 0, aClearance - m_drcEpsilon );
4312 m_worstClearance( 0 )
4322 virtual ~VIA_PLACER()
4326 void sizeMicrovia(
PCB_VIA* aVia )
4333 bool checkDRCViolation(
PCB_VIA* aVia )
4353 std::optional<int> selectPossibleNetsByPopupMenu( std::set<int>& aNetcodeList )
4357 std::map<int, int> menuIDNetCodeMap;
4360 for(
int netcode : aNetcodeList )
4367 menuText = wxString::Format(
"%s\t",
4370 menuText = wxString::Format(
"&%d %s\t",
4381 menuIDNetCodeMap[ menuID ] = netcode;
4391 int selectedNetCode = -1;
4392 bool cancelled =
false;
4398 evt->SetPassEvent();
4402 std::optional<int>
id = evt->GetCommandId();
4405 if(
id && ( *
id > 0 ) && ( *
id < menuID ) )
4407 selectedNetCode = menuIDNetCodeMap.at( *
id );
4422 return std::optional<int>();
4424 return selectedNetCode;
4427 std::optional<int> findStitchedZoneNet(
PCB_VIA* aVia )
4431 std::set<int> netcodeList;
4441 if( z->IsOnLayer(
m_frame->GetActiveLayer() ) )
4443 if( z->HitTestFilledArea(
m_frame->GetActiveLayer(), position ) )
4444 netcodeList.insert( z->GetNetCode() );
4451 if( netcodeList.size() == 1 )
4452 return *netcodeList.begin();
4459 if( z->GetIsRuleArea() )
4464 if( z->IsOnLayer( layer ) )
4466 if( z->HitTestFilledArea( layer, position ) )
4467 netcodeList.insert( z->GetNetCode() );
4473 if( netcodeList.size() == 1 )
4474 return *netcodeList.begin();
4476 if( netcodeList.size() > 1 )
4479 return selectPossibleNetsByPopupMenu( netcodeList );
4504 SEG trackSeg( track->GetStart(), track->GetEnd() );
4514 if(
PAD*
pad = findPad(
via, position ) )
4525 if( shape->IsAnyFill() )
4531 double shapeArea = poly.
Area();
4533 int R =
via->GetWidth( shape->GetLayer() ) / 2;
4534 double viaArea =
M_PI * R * R;
4536 if( viaArea * 4 > shapeArea )
4541 switch( shape->GetShape() )
4545 SEG seg( shape->GetStart(), shape->GetEnd() );
4553 if( ( shape->GetEnd() - position ).SquaredEuclideanNorm() <
4554 ( shape->GetStart() - position ).SquaredEuclideanNorm() )
4568 if( !shape->IsPolyShapeValid() )
4575 std::optional<SEG> nearestSeg;
4576 int minDist = std::numeric_limits<int>::max();
4585 int dist = seg.
Distance( position );
4587 if( dist < minDist )
4626 via->SetIsFree(
false );
4630 via->SetNetCode(
pad->GetNetCode() );
4631 via->SetIsFree(
false );
4636 via->SetIsFree(
false );
4640 std::optional<int> netcode = findStitchedZoneNet(
via );
4642 if( !netcode.has_value() )
4645 via->SetNetCode( netcode.value() );
4646 via->SetIsFree(
via->GetNetCode() > 0 );
4654 sizeMicrovia(
via );
4656 bool violatesDRC = checkDRCViolation(
via );
4661 m_frame->ShowInfoBarError(
_(
"Via location violates DRC." ),
true,
4662 WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
4664 if( !m_allowDRCViolations )
4669 if( infobar->
GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION )
4678 if( track && m_gridHelper.
GetSnap() )
4682 SEG trackSeg( trackStart, trackEnd );
4684 if( viaPos == trackStart || viaPos == trackEnd )
4698 newTrack->
SetEnd( trackEnd );
4699 aCommit.
Add( newTrack );
4705 std::unique_ptr<BOARD_ITEM> CreateItem()
override
4710 via->SetNetCode( 0 );
4724 if( first_layer !=
m_frame->GetScreen()->m_Route_Layer_TOP )
4725 last_layer =
m_frame->GetScreen()->m_Route_Layer_TOP;
4727 last_layer =
m_frame->GetScreen()->m_Route_Layer_BOTTOM;
4729 via->SetLayerPair( first_layer, last_layer );
4734 sizeMicrovia(
via );
4742 return std::unique_ptr<BOARD_ITEM>(
via );
4746 VIA_PLACER placer(
frame() );
4757 const wxString& aCommitLabel,
4771 std::optional<VECTOR2D> startingPoint;
4793 while( aDrawer( originalEvent, &shape, startingPoint ) )
4797 commit.
Add( shape );
4799 std::vector<PCB_CONSTRAINT*> snaps;
4804 commit.
Push( aCommitLabel );
4809 shape = makeShape();
4810 startingPoint = std::nullopt;
ARC_DRAW_MODE
Construction sequence used when interactively drawing a circular arc.
@ TANGENT
End only; start and departure direction come from a tangent seed.
ARC_DRAW_MODE StartArcDrawMode(const TOOL_EVENT &aEvent, APP_SETTINGS_BASE *aSettings, SHAPE_DRAW_BEHAVIOR &aBehavior)
Pick the mode a Draw Arc action starts in and apply it to aBehavior.
std::optional< ARC_TANGENT_SEED > ArcTangentSeedNear(const EDA_SHAPE &aShape, const VECTOR2I &aNear)
Seed the next tangent arc from whichever endpoint of aShape lies nearest aNear.
std::optional< ARC_TANGENT_SEED > ArcTangentSeedAt(const SEG &aSegment, const VECTOR2I &aPoint, int aTolerance)
Tangent seed for a point on or near a segment, arc or Bezier shape.
constexpr int ARC_SEED_PICK_PIXELS
Screen distance in pixels within which a click picks a graphic to start a tangent arc from.
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 cycleArcDrawMode
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
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
ARC_DRAW_MODE m_ArcDrawMode
Construction sequence last used by the arc drawing tool in this application.
Interactive arc drawing behaviour.
Arc drawing mode and tangent seed bookkeeping for one pass of an editor's managed-shape draw loop.
void PlacePoint(const VECTOR2I &aMouse, const VECTOR2I &aPos)
Lock in a point, or seed a tangent arc from the graphic under it when it would be the arc's first poi...
void RemoveLastPoint()
Undo the last point. A seed taken from a click is undone too, one from a chain is kept.
bool HandleModeEvent(const TOOL_EVENT &aEvent)
Handle a mode or cycle action; return true if aEvent was one.
Interactive bezier drawing behaviour: start -> control1 -> end -> control2.
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,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
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()
A collection of nets and the parameters used to route or test these nets.
int GetuViaDiameter() const
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 drawArcStartEndCenter
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 drawArcStartDirEnd
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 placeSubGrid
Grid Item.
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 drawArcCenter
static TOOL_ACTION drawArcTangent
static TOOL_ACTION ddImportGraphics
static TOOL_ACTION placeBarcode
static TOOL_ACTION placePoint
static TOOL_ACTION closeOutline
static TOOL_ACTION amplIncrease
static const TOOL_ACTION & DrawArcForMode(ARC_DRAW_MODE aMode)
Tool action that starts the arc tool in the given mode.
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 drawArcStartEndMid
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 KIGFX::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
void SetSizeFromRules(int aDiameter, int aDrill)
Give the via a uniform padstack sized from its diameter and hole rules.
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 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 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
Interface for receiving POLYGON_GEOM_MANAGER update.
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.
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
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< PCB_SHAPE * > CollectConstraintShapes(BOARD *aBoard, PCB_LAYER_ID aLayer)
Every PCB_SHAPE on a visible layer (drawings plus footprint graphics) – the candidates constraints ca...
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 ROUTER_TRANSIENT
transient items that should NOT be cached
#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)
Clamp a vector to values that can be negated, respecting numeric limits of coordinates data type with...
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
Are we creating copper theiving zone?
ZONE_MODE m_mode
The zone mode to operate in.
bool m_keepout
Should create a keepout zone?
ZONE * m_sourceZone
Zone settings source (for similar and cutout zones)
PCB_LAYER_ID m_layer
Layer to begin drawing.
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.