28#include "dialog_table_properties.h"
34#include <dialogs/dialog_text_properties.h>
55#include <wx/filedlg.h>
91 SetIcon( BITMAPS::width_track_via );
112 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
121 if(
via.m_Drill > 0 )
123 msg.Printf(
_(
"Via %s, hole %s" ),
129 msg.Printf(
_(
"Via %s" ),
134 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
143 int id = aEvent.GetId();
152 if( sizeDlg.ShowModal() == wxID_OK )
173 m_controls( nullptr ),
177 m_inDrawingTool( false ),
180 m_pickerItem( nullptr ),
181 m_tuningPattern( nullptr )
201 auto activeToolFunctor =
218 auto canCloseOutline =
238 auto tuningToolActive =
265 std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
266 viaSizeMenu->SetTool(
this );
268 ctxMenu.
AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
276 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus(
m_menu );
288 m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
348 std::optional<VECTOR2D> startingPoint;
349 std::stack<PCB_SHAPE*> committedLines;
360 while(
drawShape( aEvent, &line, startingPoint, &committedLines ) )
365 commit.
Push(
_(
"Draw Line" ) );
367 committedLines.push( line );
371 startingPoint = std::nullopt;
398 std::optional<VECTOR2D> startingPoint;
401 rect->
SetShape( SHAPE_T::RECTANGLE );
411 while(
drawShape( aEvent, &rect, startingPoint,
nullptr ) )
415 bool cancelled =
false;
429 commit.
Push( isTextBox ?
_(
"Draw Text Box" ) :
_(
"Draw Rectangle" ) );
436 rect->
SetShape( SHAPE_T::RECTANGLE );
439 startingPoint = std::nullopt;
460 std::optional<VECTOR2D> startingPoint;
462 circle->
SetShape( SHAPE_T::CIRCLE );
472 while(
drawShape( aEvent, &circle, startingPoint,
nullptr ) )
476 commit.
Add( circle );
477 commit.
Push(
_(
"Draw Circle" ) );
483 circle->
SetShape( SHAPE_T::CIRCLE );
487 startingPoint = std::nullopt;
508 std::optional<VECTOR2D> startingPoint;
519 while(
drawArc( aEvent, &arc, startingPoint ) )
524 commit.
Push(
_(
"Draw Arc" ) );
533 startingPoint = std::nullopt;
548 bool immediateMode =
image !=
nullptr;
550 bool ignorePrimePosition =
false;
562 image->SetPosition( cursorPos );
608 ignorePrimePosition =
true;
617 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
642 else if( evt->IsActivate() )
644 if(
image && evt->IsMoveTool() )
647 evt->SetPassEvent(
false );
654 evt->SetPassEvent(
false );
658 if( evt->IsMoveTool() )
675 wxFileDialog dlg(
m_frame,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
676 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
679 if( dlg.ShowModal() != wxID_OK )
685 if( evt->IsPrime() && !ignorePrimePosition )
687 cursorPos =
grid.Align( evt->Position() );
698 wxString fullFilename = dlg.GetPath();
700 if( wxFileExists( fullFilename ) )
703 if( !
image || !
image->ReadImageFile( fullFilename ) )
705 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
726 commit.Push(
_(
"Place Image" ) );
751 || evt->IsMotion() ) )
753 image->SetPosition( cursorPos );
797 bool ignorePrimePosition =
false;
843 ignorePrimePosition =
true;
852 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
871 else if( evt->IsActivate() )
876 if( evt->IsMoveTool() )
896 bool placing =
text !=
nullptr;
921 text->SetLayer( layer );
922 text->SetAttributes( textAttrs );
923 text->SetTextPos( cursorPos );
939 else if(
text->GetTextPos() != cursorPos )
968 commit.
Push(
_(
"Place Text" ) );
980 if( evt->IsPrime() && !ignorePrimePosition )
982 cursorPos = evt->Position();
997 else if(
text && ( evt->IsMotion()
1000 text->SetPosition( cursorPos );
1017 evt->SetPassEvent();
1092 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1099 if( evt->IsCancelInteractive() || ( table && evt->IsAction( &
ACTIONS::undo ) ) )
1111 else if( evt->IsActivate() )
1116 if( evt->IsMoveTool() )
1135 else if( evt->IsClick(
BUT_LEFT ) )
1176 commit.
Push(
_(
"Draw Table" ) );
1194 VECTOR2I requestedSize( cursorPos - origin );
1196 int colCount = std::max( 1, requestedSize.
x / ( fontSize.
x * 15 ) );
1197 int rowCount = std::max( 1, requestedSize.
y / ( fontSize.
y * 3 ) );
1199 VECTOR2I cellSize( std::max( fontSize.
x * 5, requestedSize.
x / colCount ),
1200 std::max( fontSize.
y * 3, requestedSize.
y / rowCount ) );
1202 cellSize.
x =
KiROUND( (
double) cellSize.
x / gridSize.
x ) * gridSize.
x;
1203 cellSize.
y =
KiROUND( (
double) cellSize.
y / gridSize.
y ) * gridSize.
y;
1208 for(
int col = 0; col < colCount; ++col )
1211 for(
int row = 0; row < rowCount; ++row )
1215 for(
int col = 0; col < colCount; ++col )
1241 evt->SetPassEvent();
1275 enum DIMENSION_STEPS
1290 int step = SET_ORIGIN;
1306 dimension =
nullptr;
1335 if( step > SET_ORIGIN )
1341 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1349 grid.SetUseGrid(
false );
1359 if( evt->IsCancelInteractive() || ( dimension && evt->IsAction( &
ACTIONS::undo ) ) )
1363 if( step != SET_ORIGIN )
1373 else if( evt->IsActivate() )
1375 if( step != SET_ORIGIN )
1378 if( evt->IsPointEditor() )
1382 else if( evt->IsMoveTool() )
1428 auto setMeasurementAttributes =
1442 setMeasurementAttributes( dimension );
1447 setMeasurementAttributes( dimension );
1456 setMeasurementAttributes( dimension );
1465 wxFAIL_MSG( wxT(
"Unhandled action in DRAWING_TOOL::DrawDimension" ) );
1468 t = dimension->
Type();
1478 dimension->
SetEnd( cursorPos );
1487 preview.
Add( dimension );
1518 preview.
Remove( dimension );
1520 commit.
Add( dimension );
1521 commit.
Push(
_(
"Draw Dimension" ) );
1532 if( ++step >= FINISHED )
1534 dimension =
nullptr;
1539 else if( evt->IsDblClick(
BUT_LEFT ) )
1544 else if( evt->IsMotion() )
1549 dimension->
SetEnd( cursorPos );
1573 textOffset = -textOffset;
1582 textOffset = -textOffset;
1596 double angle = aligned->
GetAngle() + ( M_PI / 2 );
1599 double height = (
delta.x * cos( angle ) ) + (
delta.y * sin( angle ) );
1637 ortho->SetHeight( vert ? heightVector.
x : heightVector.
y );
1669 if( step == SET_END || step == SET_HEIGHT )
1688 evt->SetPassEvent();
1692 if( step != SET_ORIGIN )
1720 int dlgResult = dlg.ShowModal();
1724 if( dlgResult != wxID_OK )
1730 wxMessageBox(
_(
"No graphic items found in file.") );
1736 std::vector<BOARD_ITEM*> newItems;
1737 std::vector<BOARD_ITEM*> selectedItems;
1748 newItems.push_back(
group );
1749 selectedItems.push_back(
group );
1755 std::vector<PCB_SHAPE*> shapeList;
1756 std::vector<std::unique_ptr<PCB_SHAPE>> newShapes;
1758 for(
const std::unique_ptr<EDA_ITEM>& ptr : list )
1761 shapeList.push_back( shape );
1766 for( std::unique_ptr<PCB_SHAPE>& ptr : newShapes )
1769 list.push_back( std::move( ptr ) );
1773 for( std::unique_ptr<EDA_ITEM>& ptr : list )
1776 wxCHECK2( item,
continue );
1778 newItems.push_back( item );
1782 group->AddItem( item );
1787 selectedItems.push_back( item );
1792 preview.
Add( item );
1798 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
1807 commit.
Stage( groupUndoList );
1809 commit.
Push(
_(
"Import Graphics" ) );
1845 item->Move(
delta );
1855 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1861 if( evt->IsCancelInteractive() || evt->IsActivate() )
1876 else if( evt->IsMotion() )
1881 item->Move(
delta );
1896 commit.
Stage( groupUndoList );
1898 commit.
Push(
_(
"Import Graphics" ) );
1908 evt->SetPassEvent();
1965 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1980 commit.
Push(
_(
"Move Footprint Anchor" ) );
1991 else if( evt->IsCancelInteractive() || evt->IsActivate() )
1998 evt->SetPassEvent();
2011#define TOGGLE( a ) a = !a
2043 std::optional<VECTOR2D> aStartingPoint,
2044 std::stack<PCB_SHAPE*>* aCommittedGraphics )
2046 SHAPE_T shape = ( *aGraphic )->GetShape();
2049 wxASSERT( shape == SHAPE_T::SEGMENT || shape == SHAPE_T::CIRCLE || shape == SHAPE_T::RECTANGLE );
2086 bool started =
false;
2087 bool cancelled =
false;
2105 if( !isLocalOriginSet )
2116 if( aStartingPoint )
2128 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2134 if( evt->IsCancelInteractive() || ( started && evt->IsAction( &
ACTIONS::undo ) ) )
2141 evt->SetPassEvent(
false );
2148 else if( evt->IsActivate() )
2150 if( evt->IsPointEditor() )
2154 else if( evt->IsMoveTool() )
2207 evt->SetPassEvent();
2226 if( aStartingPoint )
2228 cursorPos = *aStartingPoint;
2229 aStartingPoint = std::nullopt;
2244 grid.SetSkipPoint( cursorPos );
2247 twoPointMgr.
SetEnd( cursorPos );
2249 if( !isLocalOriginSet )
2271 if( shape == SHAPE_T::SEGMENT && snapItem && graphic->
GetLength() > 0 )
2276 commit.
Add( graphic );
2277 commit.
Push(
_(
"Draw Line" ) );
2290 twoPointMgr.
Reset();
2296 else if( evt->IsMotion() )
2298 VECTOR2I clampedCursorPos = cursorPos;
2300 if( shape == SHAPE_T::CIRCLE || shape == SHAPE_T::ARC )
2318 twoPointMgr.
SetEnd( clampedCursorPos );
2329 if( aCommittedGraphics && !aCommittedGraphics->empty() )
2331 twoPointMgr.
SetOrigin( aCommittedGraphics->top()->GetStart() );
2332 twoPointMgr.
SetEnd( aCommittedGraphics->top()->GetEnd() );
2333 aCommittedGraphics->pop();
2385 isLocalOriginSet =
true;
2386 evt->SetPassEvent();
2393 twoPointAsst.
SetUnits( userUnits );
2396 evt->SetPassEvent();
2400 evt->SetPassEvent();
2404 if( !isLocalOriginSet )
2450 std::optional<VECTOR2D> aStartingPoint )
2452 wxCHECK( aGraphic,
false );
2456 wxCHECK( graphic,
false );
2489 *aGraphic =
nullptr;
2497 bool started =
false;
2498 bool cancelled =
false;
2502 if( aStartingPoint )
2516 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2522 if( evt->IsCancelInteractive() || ( started && evt->IsAction( &
ACTIONS::undo ) ) )
2529 evt->SetPassEvent(
false );
2536 else if( evt->IsActivate() )
2538 if( evt->IsPointEditor() )
2542 else if( evt->IsMoveTool() )
2557 else if( evt->IsClick(
BUT_LEFT ) )
2577 preview.
Add( graphic );
2582 arcManager.
AddPoint( cursorPos,
true );
2588 else if( evt->IsMotion() )
2594 arcManager.
AddPoint( cursorPos,
false );
2621 evt->SetPassEvent();
2645 evt->SetPassEvent();
2688 evt->SetPassEvent();
2697 evt->SetPassEvent();
2717 preview.
Remove( graphic );
2735 bool clearSelection =
false;
2739 if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
2747 clearSelection =
true;
2758 if( clearSelection )
2786 ZONE* sourceZone =
nullptr;
2797 params.
m_mode = zoneMode;
2801 if( zoneMode == ZONE_MODE::SIMILAR && !sourceZone->
IsOnLayer( params.
m_layer ) )
2808 bool started =
false;
2822 polyGeomMgr.
Reset();
2824 grid.ClearSkipPoint();
2846 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2857 if( evt->IsCancelInteractive() )
2868 evt->SetPassEvent(
false );
2872 else if( evt->IsActivate() )
2877 if( evt->IsPointEditor() )
2881 else if( evt->IsMoveTool() )
2894 if( zoneMode != ZONE_MODE::SIMILAR )
2916 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
2923 polyGeomMgr.
Reset();
2930 else if( polyGeomMgr.
AddPoint( cursorPos ) )
2953 cursorPos = last.value();
2963 else if( started && ( evt->IsMotion()
2989 evt->SetPassEvent();
3011 std::shared_ptr<DRC_ENGINE> m_drcEngine;
3013 int m_worstClearance;
3014 bool m_allowDRCViolations;
3021 m_worstClearance( 0 )
3039 m_worstClearance = std::max( m_worstClearance, constraint.
GetValue().
Min() );
3043 for(
PAD*
pad : footprint->Pads() )
3045 std::optional<int> padOverride =
pad->GetClearanceOverrides(
nullptr );
3047 if( padOverride.has_value() )
3048 m_worstClearance = std::max( m_worstClearance, padOverride.value() );
3057 virtual ~VIA_PLACER()
3067 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3069 std::vector<PCB_TRACK*> possible_tracks;
3071 wxCHECK( view,
nullptr );
3073 view->
Query( bbox, items );
3089 possible_tracks.push_back( track );
3095 int min_d = std::numeric_limits<int>::max();
3097 for(
PCB_TRACK* track : possible_tracks )
3099 SEG test( track->GetStart(), track->GetEnd() );
3105 return_track = track;
3109 return return_track;
3117 ZONE* zone =
dynamic_cast<ZONE*
>( aOther );
3129 int connectedItemNet = connectedItem->
GetNetCode();
3131 if( connectedItemNet == 0 || connectedItemNet == aVia->
GetNetCode() )
3144 if( clearance >= 0 )
3149 if( viaShape->Collide( otherShape.get(), clearance - m_drcEpsilon ) )
3160 if( clearance >= 0 )
3165 clearance - m_drcEpsilon ) )
3175 bool checkDRCViolation(
PCB_VIA* aVia )
3177 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3178 std::set<BOARD_ITEM*> checkedItems;
3181 bbox.
Inflate( m_worstClearance );
3184 for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
3204 else if( checkedItems.count( item ) )
3209 if( hasDRCViolation( aVia, item ) )
3212 checkedItems.insert( item );
3229 for(
FOOTPRINT* fp : m_board->Footprints() )
3231 for(
PAD*
pad : fp->Pads() )
3233 if(
pad->HitTest( position ) && (
pad->GetLayerSet() & lset ).any() )
3235 if(
pad->GetNetCode() > 0 )
3244 int selectPossibleNetsByPopMenu( std::list<int>& aNetcodeList )
3248 std::map<int, int> menuIDNetCodeMap;
3251 for(
int netcode : aNetcodeList )
3257 menuText = wxString::Format(
"%s\t",
3260 menuText = wxString::Format(
"&%d %s\t",
3270 menu.
Add( menuText, menuID, BITMAPS::INVALID_BITMAP );
3271 menuIDNetCodeMap[ menuID ] = netcode;
3281 int selectNetCode = -1;
3286 evt->SetPassEvent();
3290 std::optional<int>
id = evt->GetCommandId();
3293 if(
id && ( *
id > 0 ) && ( *
id < menuID ) )
3295 selectNetCode = menuIDNetCodeMap.at( *
id );
3311 return selectNetCode;
3314 int findStitchedZoneNet(
PCB_VIA* aVia )
3327 for(
ZONE* z : m_board->Zones() )
3331 if( z->HitTestFilledArea( m_frame->
GetActiveLayer(), position ) )
3332 return z->GetNetCode();
3339 LSET tempLset =
LSET( m_board->GetVisibleLayers() & lset );
3340 std::list<int> netcodeList;
3344 if( 1 != tempLset.
Seq().size() )
3351 for(
ZONE* z : m_board->Zones() )
3355 if( z->IsOnLayer( layer ) )
3357 if( z->HitTestFilledArea( layer, position ) )
3358 netcodeList.push_back( z->GetNetCode() );
3365 netcodeList.unique();
3367 if( netcodeList.size() == 1 )
3369 return netcodeList.front();
3374 if( netcodeList.size() > 1 )
3376 return selectPossibleNetsByPopMenu( netcodeList );
3391 if( settings->
tracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS && m_gridHelper.
GetSnap() )
3403 else if( settings->
pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS && m_gridHelper.
GetSnap() )
3425 via->SetIsFree(
false );
3429 via->SetNetCode(
pad->GetNetCode() );
3430 via->SetIsFree(
false );
3434 int netcode = findStitchedZoneNet(
via );
3441 via->SetNetCode( netcode );
3442 via->SetIsFree(
via->GetNetCode() > 0 );
3445 if( checkDRCViolation(
via ) )
3450 if( !m_allowDRCViolations )
3464 if( track && m_gridHelper.
GetSnap() )
3468 SEG trackSeg( trackStart, trackEnd );
3473 auto insertChevron =
3476 if( ( trackStart - *joint1 ).SquaredEuclideanNorm()
3477 > ( trackStart - *joint2 ).SquaredEuclideanNorm() )
3479 std::swap( joint1, joint2 );
3484 track->
SetEnd( *joint1 );
3486 if( *joint1 != viaPos )
3489 wxCHECK( newTrack, );
3493 newTrack->
SetEnd( viaPos );
3494 aCommit.
Add( newTrack );
3497 if( *joint2 != viaPos )
3500 wxCHECK( newTrack, );
3504 newTrack->
SetEnd( *joint2 );
3505 aCommit.
Add( newTrack );
3509 wxCHECK( newTrack, );
3513 newTrack->
SetEnd( trackEnd );
3514 aCommit.
Add( newTrack );
3517 if( viaPos == trackStart || viaPos == trackEnd )
3520 if( trackStart.
x == trackEnd.
x )
3524 if( splitPt.
x != viaPos.
x
3525 && abs( splitPt.
x - viaPos.
x ) < abs( splitPt.
y - trackStart.
y )
3526 && abs( splitPt.
x - viaPos.
x ) < abs( splitPt.
y - trackEnd.
y ) )
3528 int offset = abs( splitPt.
x - viaPos.
x );
3530 joint1 =
VECTOR2I( splitPt.
x, splitPt.
y - offset );
3531 joint2 =
VECTOR2I( splitPt.
x, splitPt.
y + offset );
3537 else if( trackStart.
y == trackEnd.
y )
3541 if( splitPt.
y != viaPos.
y
3542 && abs( trackStart.
y - viaPos.
y ) < abs( trackStart.
x - viaPos.
x )
3543 && abs( trackEnd.
y - viaPos.
y ) < abs( trackEnd.
x - viaPos.
x ) )
3545 int offset = abs( splitPt.
y - viaPos.
y );
3547 joint1 =
VECTOR2I( splitPt.
x - offset, splitPt.
y );
3548 joint2 =
VECTOR2I( splitPt.
x + offset, splitPt.
y );
3554 else if( abs( trackStart.
y - trackEnd.
y ) == abs( trackStart.
x - trackEnd.
x ) )
3561 joint1 = trackSeg.
Intersect( horiz,
true,
true );
3562 joint2 = trackSeg.
Intersect( vert,
true,
true );
3564 if( !joint1 || !joint2 )
3580 newTrack->
SetEnd( trackEnd );
3581 aCommit.
Add( newTrack );
3587 std::unique_ptr<BOARD_ITEM> CreateItem()
override
3592 via->SetNetCode( 0 );
3613 switch(
via->GetViaType() )
3615 case VIATYPE::BLIND_BURIED:
3616 via->SetLayerPair( first_layer, last_layer );
3619 case VIATYPE::MICROVIA:
3622 ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
3624 if( first_layer ==
B_Cu )
3625 last_layer = last_inner_layer;
3626 else if( first_layer ==
F_Cu )
3628 else if( first_layer == last_inner_layer )
3630 else if( first_layer ==
In1_Cu )
3634 via->SetLayerPair( first_layer, last_layer );
3648 return std::unique_ptr<BOARD_ITEM>(
via );
3652 VIA_PLACER placer(
frame() );
constexpr EDA_IU_SCALE pcbIUScale
static TOOL_ACTION cancelInteractive
static TOOL_ACTION updateUnits
static TOOL_ACTION activatePointEditor
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION refreshPreview
static TOOL_ACTION resetLocalCoords
void SetLayerVisible(int aLayer, bool isVisible)
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
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
std::shared_ptr< DRC_ENGINE > m_DRCEngine
bool m_UseConnectedTrackWidth
bool m_DimensionSuppressZeroes
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
int GetDRCEpsilon() const
unsigned GetViaSizeIndex() const
bool m_DimensionKeepTextAligned
VECTOR2I GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
int GetCurrentViaDrill() const
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
std::vector< VIA_DIMENSION > m_ViasDimensionsList
int m_DimensionExtensionOffset
int m_DimensionArrowLength
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
virtual bool HasHole() const
FOOTPRINTS & Footprints()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
coord_type GetTop() const
coord_type GetHeight() const
coord_type GetWidth() const
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
coord_type GetRight() const
coord_type GetLeft() const
coord_type GetBottom() const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
bool ShouldFixDiscontinuities()
bool IsPlacementInteractive()
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
SEVERITY GetSeverity() const
const MINOPTMAX< int > & GetValue() const
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool IsType(FRAME_T aType) const
WX_INFOBAR * GetInfoBar()
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void DisplayConstraintsMsg(const wxString &msg)
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void SetPosition(const VECTOR2I &aPos)
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
void SetCenter(const VECTOR2I &aCenter)
void SetFilled(bool aFlag)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
void SetShape(SHAPE_T aShape)
void SetEnd(const VECTOR2I &aEnd)
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual bool IsVisible() const
void SetTextPos(const VECTOR2I &aPoint)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetItalic(bool aItalic)
A color representation with 4 components: red, green, blue, alpha.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Represents an assistant draw when interactively drawing an arc on a canvas.
void SetUnits(EDA_UNITS aUnits)
Manage the construction of a circular arc though sequential setting of critical points: center,...
VECTOR2I GetOrigin() const
< Get the center point of the arc (valid when state > SET_ORIGIN)
void SetAngleSnap(bool aSnap)
ARC_STEPS GetStep() const
Get the current step the manager is on (useful when drawing something depends on the current state)
void ToggleClockwise()
Set angle snapping (for the next point)
VECTOR2I GetStartRadiusEnd() const
Get the coordinates of the arc end point.
VECTOR2I GetEndRadiusEnd() const
Get the radius of the arc (valid if step >= SET_START)
EDA_ANGLE GetSubtended() const
@ SET_ANGLE
Waiting to lock in the arc end point.
@ SET_START
Waiting to lock in the arc start point.
bool HasGeometryChanged() const
void AddPoint(const VECTOR2I &aPt, bool aLockIn)
Add a point to the construction manager.
void RemoveLastPoint()
Undo the last point, and move the manager back to the previous step.
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(bool 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.
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
void ShowPreview(bool aShow=true)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
void RecacheAllItems()
Rebuild GAL display lists.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
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.
NETINFO_ITEM * GetNetItem(int aNetCode) const
static TOOL_ACTION deleteLastPoint
static TOOL_ACTION toggleHV45Mode
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION setAnchor
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION drawCircle
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
static TOOL_ACTION tuneDiffPair
static TOOL_ACTION trackViaSizeChanged
static TOOL_ACTION layerChanged
static TOOL_ACTION drawTable
static TOOL_ACTION drawTextBox
static TOOL_ACTION drawZoneCutout
static TOOL_ACTION drawPolygon
static TOOL_ACTION drawRadialDimension
static TOOL_ACTION tuneSingleTrack
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION drawLeader
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION placeCharacteristics
static TOOL_ACTION tuneSkew
static TOOL_ACTION incWidth
Increase width of currently drawn line.
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 selectItem
Select an item (specified as the event parameter).
static TOOL_ACTION arcPosture
Switch posture when drawing arc.
static TOOL_ACTION closeOutline
static TOOL_ACTION amplIncrease
static TOOL_ACTION amplDecrease
static TOOL_ACTION spacingIncrease
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static TOOL_ACTION drawLine
static TOOL_ACTION placeStackup
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION drawZone
Common, abstract interface for edit frames.
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
virtual void OnEditItemRequest(BOARD_ITEM *aItem)
Install the corresponding dialog editor for the given item.
void ClearListAndDeleteItems(PICKED_ITEMS_LIST *aList)
int ShowTextBoxPropertiesDialog(PCB_TEXTBOX *aTextBox)
APPEARANCE_CONTROLS * GetAppearancePanel()
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
void SetObjectVisible(GAL_LAYER_ID aLayer, bool aVisible=true)
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
virtual PCB_LAYER_ID GetActiveLayer() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
void Update()
Update the dimension's cached text and geometry.
int GetLineThickness() const
void SetExtensionOffset(int aOffset)
void SetLineThickness(int aWidth)
void SetArrowLength(int aLength)
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
int GetArrowLength() const
virtual const VECTOR2I & GetEnd() const
For better understanding of the points that make a dimension:
double GetAngle() const
Return the angle of the crossbar.
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
The main frame for Pcbnew.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
A set of BOARD_ITEMs (i.e., without duplicates).
Object to handle a bitmap image that can be inserted in a PCB.
PCB_LAYER_ID m_Route_Layer_TOP
PCB_LAYER_ID m_Route_Layer_BOTTOM
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
void SetPosition(const VECTOR2I &aPos) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
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 SetColWidth(int aCol, int aWidth)
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
void AddCell(PCB_TABLECELL *aCell)
void SetColCount(int aCount)
VECTOR2I GetPosition() const override
void SetRowHeight(int aRow, int aHeight)
void SetPosition(const VECTOR2I &aPos) 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 BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
VECTOR2I GetPosition() const override
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
unsigned GetCount() const
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.
@ DIRECT
Unconstrained point-to-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.
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
virtual void Add(EDA_ITEM *aItem)
virtual void Remove(EDA_ITEM *aItem)
virtual void Clear() override
Remove all the stored items from the group.
int Size() const
Returns the number of selected parts.
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
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,...
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
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().
EDA_UNITS GetUserUnits() const
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
An adjunct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry changes from ...
void OnGeometryChange(const POLYGON_GEOM_MANAGER &aMgr) override
Called when the polygon is complete.
Handle a list of polygons defining a copper zone.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
bool GetDoNotAllowVias() const
SHAPE_POLY_SET * Outline()
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
PCB_LAYER_ID GetFirstLayer() const
This file is part of the common library.
@ HOLE_CLEARANCE_CONSTRAINT
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
void ConnectBoardShapes(std::vector< PCB_SHAPE * > &aShapeList, std::vector< std::unique_ptr< PCB_SHAPE > > &aNewShapes, int aChainingEpsilon)
Connects shapes to each other, making continious contours (adjacent shapes will have a common vertex)...
a few functions useful in geometry calculations.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
void InferBold(TEXT_ATTRIBUTES *aAttrs)
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
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)
Class to handle a set of BOARD_ITEMs.
@ ID_POPUP_PCB_SELECT_CUSTOM_WIDTH
@ ID_POPUP_PCB_SELECT_VIASIZE1
@ ID_POPUP_PCB_SELECT_VIASIZE16
int GetUserUnits()
Return the currently selected user unit value for the interface.
Class that computes missing connections on a PCB.
std::optional< VECTOR2I > OPT_VECTOR2I
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
LINE_STYLE
Dashed line types.
constexpr int mmToIU(double mm) const
A filename or source description, a problem input line, a line number, a byte offset,...
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.
ZONE_MODE m_mode
Zone settings source (for similar and cutout zones)
bool m_keepout
< Should create a keepout zone?
ZONE * m_sourceZone
Zone leader mode.
PCB_LAYER_ID m_layer
The zone mode to operate in.
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
double EuclideanNorm(const VECTOR2I &vector)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ 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_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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2< double > VECTOR2D