23#include "dialog_table_properties.h"
65#include <wx/filedlg.h>
110 if( !aBoard || !aDimension )
121 aDimension->
GetEnd(), tol );
129 auto constraint = std::make_unique<PCB_CONSTRAINT>( aParent, aType );
130 constraint->AddMember( aDimension->
m_Uuid, aDimAnchor );
131 constraint->AddMember( *arc, aTargetAnchor );
134 aCommit.
Add( constraint.release() );
143 std::optional<VECTOR2I>
end;
145 switch( aDimension->
Type() )
156 std::vector<ENDPOINT_BINDING> bindings =
162 constraint->AddMember( aDimension->
m_Uuid, binding.sourceAnchor );
163 constraint->AddMember( binding.target.m_item, binding.target.m_anchor, binding.target.m_index );
168 aCommit.
Add( constraint.release() );
178 std::vector<PCB_CONSTRAINT*> snaps;
183 aCommit.
Add( entry.constraint.release() );
185 if( entry.needsSolve )
186 snaps.push_back( added );
196 const std::vector<PCB_CONSTRAINT*>& aConstraints )
198 if( aConstraints.empty() )
212 if( !commit.
Empty() )
243 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
252 if(
via.m_Drill > 0 )
254 msg.Printf(
_(
"Via %s, hole %s" ),
260 msg.Printf(
_(
"Via %s" ),
265 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
274 int id = aEvent.GetId();
332 auto activeToolFunctor =
352 auto canCloseOutline =
367 auto canFinishShape =
381 auto tuningToolActive =
387 auto dimensionToolActive =
422 std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
423 viaSizeMenu->SetTool(
this );
424 m_menu->RegisterSubMenu( viaSizeMenu );
425 ctxMenu.
AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
483 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V, 45" ) );
486 m_frame->DisplayConstraintsMsg(
_(
"Constrain to H, V" ) );
489 m_frame->DisplayConstraintsMsg( wxString(
"" ) );
510 std::optional<VECTOR2D> startingPoint;
511 std::stack<PCB_SHAPE*> committedLines;
524 while(
drawShape( originalEvent, &line, startingPoint, &committedLines ) )
530 std::vector<PCB_CONSTRAINT*> snaps;
538 commit.
Push(
_(
"Draw Line" ) );
541 committedLines.push( line );
545 startingPoint = std::nullopt;
572 std::optional<VECTOR2D> startingPoint;
587 while(
drawShape( originalEvent, &rect, startingPoint,
nullptr ) )
591 bool cancelled =
false;
594 cancelled =
m_frame->ShowTextBoxPropertiesDialog( textbox ) != wxID_OK;
605 commit.
Push( isTextBox ?
_(
"Draw Text Box" ) :
_(
"Draw Rectangle" ) );
615 startingPoint = std::nullopt;
653 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
656 std::vector<VECTOR2D> initialPts;
675 std::optional<ARC_TANGENT_SEED> tangentSeed;
694 commit.
Add( arc.release() );
696 std::vector<PCB_CONSTRAINT*> snaps;
701 commit.
Push(
_(
"Draw Arc" ) );
707 arc = std::make_unique<PCB_SHAPE>( parent );
729 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( parent );
732 std::vector<VECTOR2D> initialPts;
756 commit.
Add( arc.release() );
758 std::vector<PCB_CONSTRAINT*> snaps;
763 commit.
Push(
_(
"Draw Elliptical Arc" ) );
769 arc = std::make_unique<PCB_SHAPE>( parent );
791 std::unique_ptr<PCB_SHAPE> bezier = std::make_unique<PCB_SHAPE>( parent );
794 std::vector<VECTOR2D> initialPts;
797 bezier->SetFlags(
IS_NEW );
819 initialPts.push_back( bezier->GetEnd() );
822 if( bezier->GetEnd() != bezier->GetBezierC2() )
824 VECTOR2D mirroredC1 = bezier->GetEnd()
825 - ( bezier->GetBezierC2() - bezier->GetEnd() );
826 initialPts.push_back( mirroredC1 );
829 PCB_SHAPE* committedBezier = bezier.get();
830 commit.
Add( bezier.release() );
832 std::vector<PCB_CONSTRAINT*> snaps;
837 commit.
Push(
_(
"Draw Bezier" ) );
847 bezier = std::make_unique<PCB_SHAPE>( parent );
849 bezier->SetFlags(
IS_NEW );
868 wxString* filename = aEvent.
Parameter<wxString*>();
875 if( !
image->GetReferenceImage().ReadImageFile( *filename ) )
877 wxMessageBox( wxString::Format(
_(
"Could not load image from '%s'." ), *filename ) );
887 bool immediateMode =
image !=
nullptr;
889 bool ignorePrimePosition =
false;
905 image->SetPosition( cursorPos );
911 m_view->RecacheAllItems();
929 m_view->RecacheAllItems();
954 ignorePrimePosition =
true;
963 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
967 const LSET snapLayers = {
m_frame->GetActiveLayer() };
971 m_controls->ForceCursorPosition(
true, cursorPos );
983 else if( evt->IsActivate() )
985 if(
image && evt->IsMoveTool() )
988 evt->SetPassEvent(
false );
994 m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel image creation." ) );
995 evt->SetPassEvent(
false );
999 if( evt->IsMoveTool() )
1002 m_frame->PushTool( originalEvent );
1014 wxFileDialog dlg(
m_frame,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
1019 bool cancelled =
false;
1024 cancelled = dlg.ShowModal() != wxID_OK;
1033 if( evt->IsPrime() && !ignorePrimePosition )
1035 cursorPos =
grid.Align( evt->Position() );
1046 wxString fullFilename = dlg.GetPath();
1048 if( wxFileExists( fullFilename ) )
1051 if( !
image || !
image->GetReferenceImage().ReadImageFile( fullFilename ) )
1053 wxMessageBox( wxString::Format(
_(
"Could not load image from '%s'." ), fullFilename ) );
1064 m_view->RecacheAllItems();
1069 m_view->ShowPreview(
true );
1073 commit.Add(
image );
1074 commit.Push(
_(
"Place Image" ) );
1096 || evt->IsMotion() ) )
1098 image->SetPosition( cursorPos );
1101 m_view->RecacheAllItems();
1114 evt->SetPassEvent();
1134 m_gridHelper( aDrawingTool.GetManager(), aFrame.GetMagneticItemsSettings() )
1140 std::unique_ptr<PCB_POINT> new_point = std::make_unique<PCB_POINT>(
m_frame.GetModel() );
1143 new_point->SetLayer( layer );
1198 bool ignorePrimePosition =
false;
1245 ignorePrimePosition =
true;
1254 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1258 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1261 m_controls->ForceCursorPosition(
true, cursorPos );
1267 else if( evt->IsCancelInteractive() || (
text && evt->IsAction( &
ACTIONS::undo ) ) )
1274 else if( evt->IsActivate() )
1279 if( evt->IsMoveTool() )
1282 m_frame->PushTool( originalEvent );
1296 bool placing =
text !=
nullptr;
1320 text->SetLayer( layer );
1321 text->SetAttributes( textAttrs );
1322 text->SetTextPos( cursorPos );
1340 else if(
text->GetTextPos() != cursorPos )
1349 if( !
m_view->IsLayerVisible(
text->GetLayer() ) )
1351 m_frame->GetAppearancePanel()->SetLayerVisible(
text->GetLayer(),
true );
1352 m_frame->GetCanvas()->Refresh();
1369 commit.
Push(
_(
"Draw Text" ) );
1381 if( evt->IsPrime() && !ignorePrimePosition )
1383 cursorPos = evt->Position();
1384 m_controls->WarpMouseCursor( cursorPos,
true );
1388 m_controls->PinCursorInsideNonAutoscrollArea(
true );
1400 text->SetPosition( cursorPos );
1417 evt->SetPassEvent();
1492 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1496 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1499 m_controls->ForceCursorPosition(
true, cursorPos );
1505 else if( evt->IsCancelInteractive() || (
table && evt->IsAction( &
ACTIONS::undo ) ) )
1512 else if( evt->IsActivate() )
1517 if( evt->IsMoveTool() )
1520 m_frame->PushTool( originalEvent );
1543 table->SetLayer( layer );
1544 table->SetColCount( 1 );
1547 table->SetLayer( layer );
1548 table->SetPosition( cursorPos );
1550 if( !
m_view->IsLayerVisible( layer ) )
1552 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1553 m_frame->GetCanvas()->Refresh();
1585 commit.
Push(
_(
"Draw Table" ) );
1599 VECTOR2I requestedSize( cursorPos - origin );
1601 int colCount = std::max( 1, requestedSize.
x / ( fontSize.
x * 15 ) );
1602 int rowCount = std::max( 1, requestedSize.
y / ( fontSize.
y * 3 ) );
1604 VECTOR2I cellSize( std::max( fontSize.
x * 5, requestedSize.
x / colCount ),
1605 std::max( fontSize.
y * 3, requestedSize.
y / rowCount ) );
1607 cellSize.
x =
KiROUND( (
double) cellSize.
x / gridSize.
x ) * gridSize.
x;
1608 cellSize.
y =
KiROUND( (
double) cellSize.
y / gridSize.
y ) * gridSize.
y;
1610 table->ClearCells();
1611 table->SetColCount( colCount );
1613 for(
int col = 0; col < colCount; ++col )
1614 table->SetColWidth( col, cellSize.
x );
1616 for(
int row = 0; row < rowCount; ++row )
1618 table->SetRowHeight( row, cellSize.
y );
1620 for(
int col = 0; col < colCount; ++col )
1625 table->AddCell( cell );
1646 evt->SetPassEvent();
1722 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1726 const LSET snapLayers = {
m_frame->GetActiveLayer() };
1729 m_controls->ForceCursorPosition(
true, cursorPos );
1735 else if( evt->IsCancelInteractive() || ( barcode && evt->IsAction( &
ACTIONS::undo ) ) )
1742 else if( evt->IsActivate() )
1747 if( evt->IsMoveTool() )
1750 m_frame->PushTool( originalEvent );
1789 if( !
m_view->IsLayerVisible( layer ) )
1791 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
1792 m_frame->GetCanvas()->Refresh();
1795 commit.
Add( barcode );
1796 commit.
Push(
_(
"Draw Barcode" ) );
1806 evt->SetPassEvent();
1830 enum DIMENSION_STEPS
1844 int step = SET_ORIGIN;
1857 m_view->Update( &preview );
1864 dimension =
nullptr;
1894 if( step > SET_ORIGIN )
1895 frame()->SetMsgPanel( dimension );
1902 if( evt->Modifier(
MD_CTRL ) )
1906 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1914 grid.SetUseGrid(
false );
1918 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
1921 m_controls->ForceCursorPosition(
true, cursorPos );
1923 if( evt->IsCancelInteractive() || ( dimension && evt->IsAction( &
ACTIONS::undo ) ) )
1927 if( step != SET_ORIGIN )
1932 else if( evt->IsActivate() )
1934 if( step != SET_ORIGIN )
1937 if( evt->IsPointEditor() )
1943 if( evt->IsMoveTool() )
1946 m_frame->PushTool( originalEvent );
1955 m_view->Update( &preview );
1956 frame()->SetMsgPanel( dimension );
1964 m_view->Update( &preview );
1965 frame()->SetMsgPanel( dimension );
1987 auto setMeasurementAttributes =
2001 setMeasurementAttributes( dimension );
2006 setMeasurementAttributes( dimension );
2015 setMeasurementAttributes( dimension );
2024 wxFAIL_MSG( wxT(
"Unhandled action in DRAWING_TOOL::DrawDimension" ) );
2027 t = dimension->
Type();
2038 dimension->
SetEnd( cursorPos );
2041 if( !
m_view->IsLayerVisible( layer ) )
2043 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2044 m_frame->GetCanvas()->Refresh();
2047 preview.
Add( dimension );
2048 frame()->SetMsgPanel( dimension );
2074 preview.
Remove( dimension );
2076 commit.
Add( dimension );
2082 commit.
Push(
_(
"Draw Dimension" ) );
2086 frame()->OnEditItemRequest( dimension );
2095 dimension =
nullptr;
2110 dimension->
SetEnd( cursorPos );
2134 textOffset = -textOffset;
2143 textOffset = -textOffset;
2160 double height = (
delta.x * cos( angle ) ) + (
delta.y * sin( angle ) );
2198 ortho->SetHeight( vert ? heightVector.
x : heightVector.
y );
2206 m_view->Update( &preview );
2212 if( !
m_view->IsLayerVisible( layer ) )
2214 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2215 m_frame->GetCanvas()->Refresh();
2225 m_view->Update( &preview );
2226 frame()->SetMsgPanel( dimension );
2230 if( step == SET_END || step == SET_HEIGHT )
2232 frame()->OnEditItemRequest( dimension );
2234 frame()->SetMsgPanel( dimension );
2244 switch( dimension->
Type() )
2259 m_view->Update( &preview );
2268 evt->SetPassEvent();
2272 if( step != SET_ORIGIN )
2280 m_view->Remove( &preview );
2311 std::vector<PCB_LAYER_ID> layerIds;
2312 wxArrayString layerNames;
2313 int selectedLayer = 0;
2317 if( layer ==
image->GetLayer() )
2318 selectedLayer = (int) layerIds.size();
2320 layerIds.push_back( layer );
2321 layerNames.Add(
m_board->GetLayerName( layer ) );
2324 auto showPreview = [&](
double aThreshold,
bool aInvert )
2328 m_frame->GetCanvas()->ForceRefresh();
2342 m_frame->GetCanvas()->ForceRefresh();
2349 double scaleX = (double) size.
x / bilevel.GetWidth();
2350 double scaleY = (double) size.
y / bilevel.GetHeight();
2354 wxString warnings =
reporter.GetMessages();
2358 const int icon = warnings.IsEmpty() ? wxICON_INFORMATION : wxICON_WARNING;
2362 wxString
message = warnings.IsEmpty() ?
_(
"No shapes to trace at this threshold." ) : warnings;
2364 m_frame->GetCanvas()->ForceRefresh();
2372 traced.
Move( origin );
2392 group->AddItem( shape );
2393 commit.
Add( shape );
2398 commit.
Push(
_(
"Convert Image to Outlines" ) );
2400 wxString
message = wxString::Format( wxPLURAL(
"Added %d shape.",
"Added %d shapes.", traced.
OutlineCount() ),
2403 if( !warnings.IsEmpty() )
2404 message << wxS(
" " ) << warnings;
2432 if( dlgResult != wxID_OK )
2438 wxMessageBox(
_(
"No graphic items found in file.") );
2444 std::vector<BOARD_ITEM*> newItems;
2445 std::vector<BOARD_ITEM*> selectedItems;
2453 size_t boardItemCount = std::count_if( list.begin(), list.end(),
2454 [](
const std::unique_ptr<EDA_ITEM>& ptr )
2456 return ptr->IsBOARD_ITEM();
2459 if( boardItemCount >= 2 )
2463 newItems.push_back(
group );
2464 selectedItems.push_back(
group );
2471 std::vector<PCB_SHAPE*> shapeList;
2473 for(
const std::unique_ptr<EDA_ITEM>& ptr : list )
2476 shapeList.push_back( shape );
2482 for( std::unique_ptr<EDA_ITEM>& ptr : list )
2484 EDA_ITEM* eda_item = ptr.release();
2490 newItems.push_back( item );
2493 group->AddItem( item );
2495 selectedItems.push_back( item );
2500 preview.
Add( eda_item );
2506 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
2514 commit.
Push(
_(
"Import Graphics" ) );
2522 if( !
m_view->IsLayerVisible( layer ) )
2524 m_frame->GetAppearancePanel()->SetLayerVisible( layer,
true );
2525 m_frame->GetCanvas()->Refresh();
2553 item->Move(
delta );
2555 m_view->Update( &preview );
2563 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2566 m_controls->ForceCursorPosition(
true, cursorPos );
2568 if( evt->IsCancelInteractive() || evt->IsActivate() )
2585 item->Move(
delta );
2587 m_view->Update( &preview );
2600 commit.
Push(
_(
"Import Graphics" ) );
2610 evt->SetPassEvent();
2615 m_view->Remove( &preview );
2665 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2667 m_controls->ForceCursorPosition(
true, cursorPos );
2678 footprint->MoveAnchorPosition( moveVector );
2680 commit.
Push(
_(
"Move Footprint Anchor" ) );
2689 else if( evt->IsCancelInteractive() || evt->IsActivate() )
2695 evt->SetPassEvent();
2724 int step = SET_CENTER;
2767 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2769 m_controls->ForceCursorPosition(
true, cursorPos );
2774 if( step == SET_CENTER )
2783 board->Add( griditem );
2790 sizeToCursor( cursorPos );
2795 board->Remove( griditem );
2798 commit.
Add( griditem );
2799 commit.
Push(
_(
"Place Sub-grid" ) );
2809 else if( evt->IsCancelInteractive() || evt->IsActivate() || ( griditem && evt->IsAction( &
ACTIONS::undo ) ) )
2811 bool restart = griditem && !evt->IsActivate();
2816 board->Remove( griditem );
2826 else if( griditem && ( evt->IsMotion()
2829 sizeToCursor( cursorPos );
2834 evt->SetPassEvent();
2851 const double cosRot = rot.
Cos();
2852 const double sinRot = rot.
Sin();
2854 const double dx = aCursorPos.
x -
center.x;
2855 const double dy = aCursorPos.
y -
center.y;
2856 const double lx = dx * cosRot + dy * sinRot;
2857 const double ly = -dx * sinRot + dy * cosRot;
2860 const double px = a * t.
Cos();
2861 const double py = b * t.
Sin();
2884 if( halfW >= halfH )
2886 majorRadius = std::max( halfW, 1 );
2887 minorRadius = std::max( halfH, 1 );
2892 majorRadius = std::max( halfH, 1 );
2893 minorRadius = std::max( halfW, 1 );
2918 std::stack<PCB_SHAPE*>* aCommittedGraphics )
2920 SHAPE_T shape = ( *aGraphic )->GetShape();
2962 m_view->Add( &twoPointAsst );
2964 bool started =
false;
2965 bool cancelled =
false;
2966 bool multiPhase =
false;
2968 bool isLocalOriginSet = (
m_frame->GetScreen()->m_LocalOrigin !=
VECTOR2D( 0, 0 ) );
2988 if( !isLocalOriginSet )
2994 VECTOR2I clampedCursorPos = aCursorPos;
3018 twoPointMgr.
SetEnd( clampedCursorPos );
3032 if( aStartingPoint )
3033 m_toolMgr->PrimeTool( *aStartingPoint );
3038 while( ( evt =
Wait() ) )
3043 m_frame->SetMsgPanel( graphic );
3071 m_controls->ForceCursorPosition(
true, cursorPos );
3127 m_frame->GetCanvas()->Refresh();
3137 frame()->SetMsgPanel( graphic );
3161 if( aStartingPoint )
3163 cursorPos = *aStartingPoint;
3164 aStartingPoint = std::nullopt;
3179 grid.SetSkipPoint( cursorPos );
3182 twoPointMgr.
SetEnd( cursorPos );
3184 if( !isLocalOriginSet )
3185 m_frame->GetScreen()->m_LocalOrigin = cursorPos;
3188 frame()->SetMsgPanel( graphic );
3195 m_frame->GetCanvas()->Refresh();
3205 else if( multiPhase )
3227 updateGraphicToCursor( cursorPos, angleSnap );
3233 m_view->Remove( &twoPointAsst );
3245 commit.
Add( graphic );
3247 std::vector<PCB_CONSTRAINT*> snaps;
3255 commit.
Push(
_(
"Draw Line" ) );
3261 else if( twoPointMgr.
IsEmpty()
3271 twoPointMgr.
Reset();
3304 frame()->SetMsgPanel( graphic );
3308 updateGraphicToCursor( cursorPos, angleSnap );
3310 m_view->Update( &twoPointAsst );
3316 if( aCommittedGraphics && !aCommittedGraphics->empty() )
3318 twoPointMgr.
SetOrigin( aCommittedGraphics->top()->GetStart() );
3319 twoPointMgr.
SetEnd( aCommittedGraphics->top()->GetEnd() );
3320 aCommittedGraphics->pop();
3337 m_view->Update( &twoPointAsst );
3350 frame()->SetMsgPanel( graphic );
3359 frame()->SetMsgPanel( graphic );
3364 frame()->OnEditItemRequest( graphic );
3366 frame()->SetMsgPanel( graphic );
3375 isLocalOriginSet =
true;
3380 if(
frame()->GetUserUnits() != userUnits )
3382 userUnits =
frame()->GetUserUnits();
3383 twoPointAsst.
SetUnits( userUnits );
3384 m_view->Update( &twoPointAsst );
3401 if( !isLocalOriginSet )
3405 m_view->Remove( &twoPointAsst );
3424 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() );
3434 const std::vector<VECTOR2D>& aInitialPts,
3435 const std::optional<ARC_TANGENT_SEED>& aTangentSeed,
3473 auto findTangentSeed =
3474 [&](
const VECTOR2I&,
const VECTOR2I& aPos ) -> std::optional<ARC_TANGENT_SEED>
3479 [&](
const PCB_SHAPE* aShape ) -> std::optional<ARC_TANGENT_SEED>
3481 if( !aShape || aShape->GetLayer() !=
m_layer )
3482 return std::nullopt;
3484 BOX2I reach = aShape->GetBoundingBox();
3487 return std::nullopt;
3492 if( std::optional<ARC_TANGENT_SEED> seed = seedFrom(
dynamic_cast<PCB_SHAPE*
>(
grid.GetSnapped() ) ) )
3497 if( std::optional<ARC_TANGENT_SEED> seed = seedFrom( shape ) )
3501 return std::nullopt;
3507 m_frame->SelectToolbarAction( PCB_ACTIONS::DrawArcForMode( aMode ) );
3508 m_toolMgr->PostAction( ACTIONS::refreshPreview );
3516 bool started =
false;
3517 bool cancelled =
false;
3518 bool finished =
false;
3524 for(
const VECTOR2D& pt : aInitialPts )
3527 if( !aInitialPts.empty() || aTangentSeed )
3541 m_frame->GetCanvas()->Refresh();
3544 preview.
Add( graphic );
3545 frame()->SetMsgPanel( graphic );
3553 while( ( evt =
Wait() ) )
3556 m_frame->SetMsgPanel( graphic );
3571 m_controls->ForceCursorPosition(
true, cursorPos );
3629 m_frame->GetCanvas()->Refresh();
3632 preview.
Add( graphic );
3633 frame()->SetMsgPanel( graphic );
3637 arcSession.
PlacePoint( cursorPos, cursorPos );
3640 *aLastClick = cursorPos;
3685 m_frame->GetCanvas()->Refresh();
3690 m_view->Update( &preview );
3691 frame()->SetMsgPanel( graphic );
3702 frame()->OnEditItemRequest( graphic );
3703 m_view->Update( &preview );
3704 frame()->SetMsgPanel( graphic );
3726 m_view->Update( &preview );
3727 frame()->SetMsgPanel( graphic );
3739 m_view->Update( &preview );
3740 frame()->SetMsgPanel( graphic );
3771 m_view->Update( &preview );
3776 frame()->SetMsgPanel( graphic );
3789 preview.
Remove( graphic );
3791 m_view->Remove( &preview );
3813 bool clearSelection =
false;
3825 clearSelection =
true;
3836 if( clearSelection )
3875 ZONE* sourceZone =
nullptr;
3887 params.
m_mode = zoneMode;
3898 bool started =
false;
3912 polyGeomMgr.
Reset();
3914 grid.ClearSkipPoint();
3943 if( evt->Modifier(
MD_CTRL ) )
3946 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3948 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
m_controls->GetMousePosition();
3951 m_controls->ForceCursorPosition(
true, cursorPos );
3955 if( evt->IsCancelInteractive() )
3964 evt->SetPassEvent(
false );
3968 else if( evt->IsActivate() )
3973 if( evt->IsPointEditor() )
3979 if( evt->IsMoveTool() )
3982 m_frame->PushTool( originalEvent );
3994 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
3995 m_frame->GetCanvas()->Refresh();
4013 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
4021 polyGeomMgr.
Reset();
4027 else if( polyGeomMgr.
AddPoint( cursorPos ) )
4038 m_frame->GetAppearancePanel()->SetLayerVisible( params.
m_layer,
true );
4039 m_frame->GetCanvas()->Refresh();
4054 cursorPos = last.value();
4056 m_controls->ForceCursorPosition(
true, cursorPos );
4064 else if( started && ( evt->IsMotion()
4091 evt->SetPassEvent();
4119 worst = std::max( worst, constraint.
GetValue().
Min() );
4123 for(
PAD*
pad : footprint->Pads() )
4125 std::optional<int> padOverride =
pad->GetClearanceOverrides(
nullptr );
4127 if( padOverride.has_value() )
4128 worst = std::max( worst, padOverride.value() );
4142 auto sub_e = [&](
int aClearance )
4144 return std::max( 0, aClearance - aEpsilon );
4150 ZONE* zone =
dynamic_cast<ZONE*
>( aOther );
4164 zoneOutline = zone->
Outline();
4177 if( zoneOutline->
Collide(
via->GetPosition(),
via->GetWidth( layer ) / 2 ) )
4190 bool skipCopper =
false;
4194 int connectedItemNet = connectedItem->
GetNetCode();
4196 if( connectedItemNet != 0 && connectedItemNet == aItem->
GetNetCode() )
4200 if( connectedItemNet == 0 )
4220 if( itemShape->Collide( otherShape.get(), sub_e(
clearance ) ) )
4245 int aWorstClearance,
int aEpsilon )
4247 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4248 std::set<BOARD_ITEM*> checkedItems;
4251 bbox.
Inflate( aWorstClearance );
4254 for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
4256 if( !it.first->IsBOARD_ITEM() )
4274 else if( checkedItems.count( item ) )
4282 checkedItems.insert( item );
4318 const LSET& aLayers,
int aSnapRange )
4320 const LSET lset = aLayers;
4323 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4325 std::vector<PCB_TRACK*> possible_tracks;
4327 wxCHECK( view,
nullptr );
4329 view->
Query( bbox, items );
4333 if( !it.first->IsBOARD_ITEM() )
4349 possible_tracks.push_back( track );
4357 possible_tracks.push_back( arc );
4362 int min_d = std::numeric_limits<int>::max();
4364 for(
PCB_TRACK* track : possible_tracks )
4366 SEG test( track->GetStart(), track->GetEnd() );
4367 int dist = (
test.NearestPoint( aPosition ) - aPosition ).EuclideanNorm();
4372 return_track = track;
4376 return return_track;
4383 const LSET lset = aLayers;
4387 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4389 view.
Query( bbox, items );
4393 if( !it.first->IsBOARD_ITEM() )
4402 if(
pad.HitTest( aPosition, aSnapRange ) )
4412 const LSET& aLayers,
int aSnapRange = 0 )
4417 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
4420 std::vector<PCB_SHAPE*> possible_shapes;
4422 view->
Query( bbox, items );
4426 if( !it.first->IsBOARD_ITEM() )
4438 if( shape->
HitTest( aPosition, std::max( aVia->
GetWidth( activeLayer ) / 2, aSnapRange ) ) )
4439 possible_shapes.push_back( shape );
4444 int min_d = std::numeric_limits<int>::max();
4446 for(
PCB_SHAPE* shape : possible_shapes )
4448 int dist = ( shape->GetPosition() - aPosition ).EuclideanNorm();
4453 return_shape = shape;
4457 return return_shape;
4475 std::shared_ptr<DRC_ENGINE> m_drcEngine;
4477 int m_worstClearance;
4478 bool m_allowDRCViolations;
4480 int sub_e(
int aClearance )
4482 return std::max( 0, aClearance - m_drcEpsilon );
4490 m_worstClearance( 0 )
4500 virtual ~VIA_PLACER()
4504 void sizeMicrovia(
PCB_VIA* aVia )
4511 bool checkDRCViolation(
PCB_VIA* aVia )
4531 std::optional<int> selectPossibleNetsByPopupMenu( std::set<int>& aNetcodeList )
4535 std::map<int, int> menuIDNetCodeMap;
4538 for(
int netcode : aNetcodeList )
4545 menuText = wxString::Format(
"%s\t",
4548 menuText = wxString::Format(
"&%d %s\t",
4559 menuIDNetCodeMap[ menuID ] = netcode;
4569 int selectedNetCode = -1;
4570 bool cancelled =
false;
4573 while( ( evt = drawingTool->
Wait() ) )
4584 if(
id && ( *
id > 0 ) && ( *
id < menuID ) )
4586 selectedNetCode = menuIDNetCodeMap.at( *
id );
4601 if( cancelled || !evt )
4602 return std::optional<int>();
4604 return selectedNetCode;
4607 std::optional<int> findStitchedZoneNet(
PCB_VIA* aVia )
4611 std::set<int> netcodeList;
4621 if( z->IsOnLayer(
m_frame->GetActiveLayer() ) )
4623 if( z->HitTestFilledArea(
m_frame->GetActiveLayer(), position ) )
4624 netcodeList.insert( z->GetNetCode() );
4631 if( netcodeList.size() == 1 )
4632 return *netcodeList.begin();
4639 if( z->GetIsRuleArea() )
4644 if( z->IsOnLayer( layer ) )
4646 if( z->HitTestFilledArea( layer, position ) )
4647 netcodeList.insert( z->GetNetCode() );
4653 if( netcodeList.size() == 1 )
4654 return *netcodeList.begin();
4656 if( netcodeList.size() > 1 )
4659 return selectPossibleNetsByPopupMenu( netcodeList );
4684 SEG trackSeg( track->GetStart(), track->GetEnd() );
4694 if(
PAD*
pad = findPad(
via, position ) )
4705 if( shape->IsAnyFill() )
4711 double shapeArea = poly.
Area();
4713 int R =
via->GetWidth( shape->GetLayer() ) / 2;
4714 double viaArea =
M_PI * R * R;
4716 if( viaArea * 4 > shapeArea )
4721 switch( shape->GetShape() )
4725 SEG seg( shape->GetStart(), shape->GetEnd() );
4733 if( ( shape->GetEnd() - position ).SquaredEuclideanNorm() <
4734 ( shape->GetStart() - position ).SquaredEuclideanNorm() )
4748 if( !shape->IsPolyShapeValid() )
4755 std::optional<SEG> nearestSeg;
4756 int minDist = std::numeric_limits<int>::max();
4765 int dist = seg.
Distance( position );
4767 if( dist < minDist )
4806 via->SetIsFree(
false );
4810 via->SetNetCode(
pad->GetNetCode() );
4811 via->SetIsFree(
false );
4816 via->SetIsFree(
false );
4820 std::optional<int> netcode = findStitchedZoneNet(
via );
4822 if( !netcode.has_value() )
4825 via->SetNetCode( netcode.value() );
4826 via->SetIsFree(
via->GetNetCode() > 0 );
4834 sizeMicrovia(
via );
4836 bool violatesDRC = checkDRCViolation(
via );
4841 m_frame->ShowInfoBarError(
_(
"Via location violates DRC." ),
true,
4842 WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
4844 if( !m_allowDRCViolations )
4849 if( infobar->
GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION )
4858 if( track && m_gridHelper.
GetSnap() )
4862 SEG trackSeg( trackStart, trackEnd );
4864 if( viaPos == trackStart || viaPos == trackEnd )
4878 newTrack->
SetEnd( trackEnd );
4879 aCommit.
Add( newTrack );
4885 std::unique_ptr<BOARD_ITEM> CreateItem()
override
4890 via->SetNetCode( 0 );
4904 if( first_layer !=
m_frame->GetScreen()->m_Route_Layer_TOP )
4905 last_layer =
m_frame->GetScreen()->m_Route_Layer_TOP;
4907 last_layer =
m_frame->GetScreen()->m_Route_Layer_BOTTOM;
4909 via->SetLayerPair( first_layer, last_layer );
4914 sizeMicrovia(
via );
4922 return std::unique_ptr<BOARD_ITEM>(
via );
4926 VIA_PLACER placer(
frame() );
4937 const wxString& aCommitLabel,
4951 std::optional<VECTOR2D> startingPoint;
4973 while( aDrawer( originalEvent, &shape, startingPoint ) )
4977 commit.
Add( shape );
4979 std::vector<PCB_CONSTRAINT*> snaps;
4984 commit.
Push( aCommitLabel );
4989 shape = makeShape();
4990 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
wxImage ConvertImageToBilevel(const wxImage &aImage, double aThreshold, bool aInvert)
Reduce an image to pure black and white.
SHAPE_POLY_SET TraceBilevelImage(const wxImage &aBilevelImage, double aScaleX, double aScaleY, REPORTER &aReporter)
Trace the black regions of a black and white image into filled polygons.
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.
This class handle bitmap images in KiCad.
void BeginPreviewImage(const wxImage &aImage)
Show finished pixels in place of the image, without disturbing the scale or the resolution.
void EndPreviewImage()
Put back the image a preview stood in for, and do nothing if none is showing.
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()
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 & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
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.
Ask for the settings used to trace a placed image into outlines.
double GetThreshold() const
Brightness cut deciding which pixels are traced, from 0 to 1.
int GetLayerSelection() const
Index into the layer names given to the constructor, or -1 when there were none.
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 convertImageToOutlines
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 ddPlaceReferenceImage
static TOOL_ACTION drawLine
static TOOL_ACTION placeViaStack
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION drawArcStartEndMid
static TOOL_ACTION drawZone
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 SetPolyShape(const SHAPE_POLY_SET &aShape) 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)
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.
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
BITMAP_BASE & MutableImage() const
Only use this if you really need to modify the underlying image.
EDA_ANGLE GetOrientation() const
VECTOR2I GetPosition() const
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.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
double Area()
Return the area of this poly set.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
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.
void Move(const VECTOR2I &aVector) override
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
A wrapper for reporting to a wxString object.
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< ENDPOINT_BINDING > SelectEndpointBindings(const 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...
std::vector< AUTO_CONSTRAINT > SelectShapeAutoConstraints(const 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.
bool ConstraintIsDuplicateOnBoard(const BOARD *aBoard, const PCB_CONSTRAINT *aConstraint)
True if the board or one of its footprints already carries an equal constraint.
std::optional< KIID > SelectRadialDimensionTarget(const 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< PCB_SHAPE * > CollectConstraintShapes(const BOARD *aBoard, PCB_LAYER_ID aLayer)
Every PCB_SHAPE on a visible layer (drawings plus footprint graphics) – the candidates constraints ca...
@ 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.
IbisParser parser & reporter
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.