28#include "dialog_table_properties.h"
34#include <dialogs/dialog_text_properties.h>
57#include <wx/filedlg.h>
94 SetIcon( BITMAPS::width_track_via );
115 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
124 if(
via.m_Drill > 0 )
126 msg.Printf(
_(
"Via %s, hole %s" ),
132 msg.Printf(
_(
"Via %s" ),
137 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
146 int id = aEvent.GetId();
176 m_controls( nullptr ),
180 m_inDrawingTool( false ),
183 m_pickerItem( nullptr ),
184 m_tuningPattern( nullptr )
204 auto activeToolFunctor =
223 auto canCloseOutline =
243 auto tuningToolActive =
249 auto dimensionToolActive =
278 std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
279 viaSizeMenu->SetTool(
this );
280 m_menu->RegisterSubMenu( viaSizeMenu );
281 ctxMenu.
AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
289 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *
m_menu.get() );
301 m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
364 std::optional<VECTOR2D> startingPoint;
365 std::stack<PCB_SHAPE*> committedLines;
376 while(
drawShape( aEvent, &line, startingPoint, &committedLines ) )
381 commit.
Push(
_(
"Draw Line" ) );
383 committedLines.push( line );
387 startingPoint = std::nullopt;
414 std::optional<VECTOR2D> startingPoint;
417 rect->
SetShape( SHAPE_T::RECTANGLE );
427 while(
drawShape( aEvent, &rect, startingPoint,
nullptr ) )
431 bool cancelled =
false;
445 commit.
Push( isTextBox ?
_(
"Draw Text Box" ) :
_(
"Draw Rectangle" ) );
452 rect->
SetShape( SHAPE_T::RECTANGLE );
455 startingPoint = std::nullopt;
476 std::optional<VECTOR2D> startingPoint;
478 circle->
SetShape( SHAPE_T::CIRCLE );
488 while(
drawShape( aEvent, &circle, startingPoint,
nullptr ) )
492 commit.
Add( circle );
493 commit.
Push(
_(
"Draw Circle" ) );
499 circle->
SetShape( SHAPE_T::CIRCLE );
503 startingPoint = std::nullopt;
524 std::optional<VECTOR2D> startingPoint;
535 while(
drawArc( aEvent, &arc, startingPoint ) )
540 commit.
Push(
_(
"Draw Arc" ) );
549 startingPoint = std::nullopt;
579 std::unique_ptr<PCB_SHAPE> bezier =
583 startingPoint = std::nullopt;
584 startingC1 = std::nullopt;
590 commit.
Add( bezier.release() );
591 commit.
Push(
_(
"Draw Bezier" ) );
596 startingPoint = bezierRef.
GetEnd();
623 bool immediateMode =
image !=
nullptr;
625 bool ignorePrimePosition =
false;
637 image->SetPosition( cursorPos );
683 ignorePrimePosition =
true;
692 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
694 { m_frame->GetActiveLayer() },
717 else if( evt->IsActivate() )
719 if(
image && evt->IsMoveTool() )
722 evt->SetPassEvent(
false );
729 evt->SetPassEvent(
false );
733 if( evt->IsMoveTool() )
750 wxFileDialog dlg(
m_frame,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
751 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
754 if( dlg.ShowModal() != wxID_OK )
760 if( evt->IsPrime() && !ignorePrimePosition )
762 cursorPos =
grid.Align( evt->Position() );
773 wxString fullFilename = dlg.GetPath();
775 if( wxFileExists( fullFilename ) )
778 if( !
image || !
image->GetReferenceImage().ReadImageFile( fullFilename ) )
780 wxMessageBox( wxString::Format(
_(
"Could not load image from '%s'." ), fullFilename ) );
801 commit.Push(
_(
"Place Image" ) );
826 || evt->IsMotion() ) )
828 image->SetPosition( cursorPos );
872 bool ignorePrimePosition =
false;
918 ignorePrimePosition =
true;
927 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
930 { m_frame->GetActiveLayer() },
GRID_TEXT ),
946 else if( evt->IsActivate() )
951 if( evt->IsMoveTool() )
971 bool placing =
text !=
nullptr;
996 text->SetLayer( layer );
997 text->SetAttributes( textAttrs );
998 text->SetTextPos( cursorPos );
1014 else if(
text->GetTextPos() != cursorPos )
1043 commit.
Push(
_(
"Draw Text" ) );
1055 if( evt->IsPrime() && !ignorePrimePosition )
1057 cursorPos = evt->Position();
1072 else if(
text && ( evt->IsMotion()
1075 text->SetPosition( cursorPos );
1092 evt->SetPassEvent();
1164 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1167 { m_frame->GetActiveLayer() },
GRID_TEXT ),
1171 if( evt->IsCancelInteractive() || ( table && evt->IsAction( &
ACTIONS::undo ) ) )
1183 else if( evt->IsActivate() )
1188 if( evt->IsMoveTool() )
1207 else if( evt->IsClick(
BUT_LEFT ) )
1248 commit.
Push(
_(
"Draw Table" ) );
1266 VECTOR2I requestedSize( cursorPos - origin );
1268 int colCount = std::max( 1, requestedSize.
x / ( fontSize.
x * 15 ) );
1269 int rowCount = std::max( 1, requestedSize.
y / ( fontSize.
y * 3 ) );
1271 VECTOR2I cellSize( std::max( fontSize.
x * 5, requestedSize.
x / colCount ),
1272 std::max( fontSize.
y * 3, requestedSize.
y / rowCount ) );
1274 cellSize.
x =
KiROUND( (
double) cellSize.
x / gridSize.
x ) * gridSize.
x;
1275 cellSize.
y =
KiROUND( (
double) cellSize.
y / gridSize.
y ) * gridSize.
y;
1280 for(
int col = 0; col < colCount; ++col )
1283 for(
int row = 0; row < rowCount; ++row )
1287 for(
int col = 0; col < colCount; ++col )
1302 frame()->OnEditItemRequest( table );
1304 frame()->SetMsgPanel( table );
1313 evt->SetPassEvent();
1347 enum DIMENSION_STEPS
1362 int step = SET_ORIGIN;
1378 dimension =
nullptr;
1407 if( step > SET_ORIGIN )
1408 frame()->SetMsgPanel( dimension );
1414 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1422 grid.SetUseGrid(
false );
1432 if( evt->IsCancelInteractive() || ( dimension && evt->IsAction( &
ACTIONS::undo ) ) )
1436 if( step != SET_ORIGIN )
1446 else if( evt->IsActivate() )
1448 if( step != SET_ORIGIN )
1451 if( evt->IsPointEditor() )
1455 else if( evt->IsMoveTool() )
1471 frame()->SetMsgPanel( dimension );
1480 frame()->SetMsgPanel( dimension );
1501 auto setMeasurementAttributes =
1515 setMeasurementAttributes( dimension );
1520 setMeasurementAttributes( dimension );
1529 setMeasurementAttributes( dimension );
1538 wxFAIL_MSG( wxT(
"Unhandled action in DRAWING_TOOL::DrawDimension" ) );
1541 t = dimension->
Type();
1552 dimension->
SetEnd( cursorPos );
1561 preview.
Add( dimension );
1562 frame()->SetMsgPanel( dimension );
1592 preview.
Remove( dimension );
1594 commit.
Add( dimension );
1595 commit.
Push(
_(
"Draw Dimension" ) );
1599 frame()->OnEditItemRequest( dimension );
1606 if( ++step >= FINISHED )
1608 dimension =
nullptr;
1613 else if( evt->IsDblClick(
BUT_LEFT ) )
1618 else if( evt->IsMotion() )
1623 dimension->
SetEnd( cursorPos );
1647 textOffset = -textOffset;
1656 textOffset = -textOffset;
1670 double angle = aligned->
GetAngle() + ( M_PI / 2 );
1673 double height = (
delta.x * cos( angle ) ) + (
delta.y * sin( angle ) );
1711 ortho->SetHeight( vert ? heightVector.
x : heightVector.
y );
1739 frame()->SetMsgPanel( dimension );
1743 if( step == SET_END || step == SET_HEIGHT )
1745 frame()->OnEditItemRequest( dimension );
1747 frame()->SetMsgPanel( dimension );
1757 switch( dimension->
Type() )
1781 evt->SetPassEvent();
1785 if( step != SET_ORIGIN )
1817 if( dlgResult != wxID_OK )
1823 wxMessageBox(
_(
"No graphic items found in file.") );
1829 std::vector<BOARD_ITEM*> newItems;
1830 std::vector<BOARD_ITEM*> selectedItems;
1841 newItems.push_back(
group );
1842 selectedItems.push_back(
group );
1848 std::vector<PCB_SHAPE*> shapeList;
1849 std::vector<std::unique_ptr<PCB_SHAPE>> newShapes;
1851 for(
const std::unique_ptr<EDA_ITEM>& ptr : list )
1854 shapeList.push_back( shape );
1859 for( std::unique_ptr<PCB_SHAPE>& ptr : newShapes )
1862 list.push_back( std::move( ptr ) );
1866 for( std::unique_ptr<EDA_ITEM>& ptr : list )
1868 EDA_ITEM* eda_item = ptr.release();
1874 newItems.push_back( item );
1878 group->AddItem( item );
1883 selectedItems.push_back( item );
1889 preview.
Add( eda_item );
1895 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
1904 commit.
Stage( groupUndoList );
1906 commit.
Push(
_(
"Import Graphics" ) );
1945 item->Move(
delta );
1955 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1961 if( evt->IsCancelInteractive() || evt->IsActivate() )
1976 else if( evt->IsMotion() )
1981 item->Move(
delta );
1996 commit.
Stage( groupUndoList );
1998 commit.
Push(
_(
"Import Graphics" ) );
2008 evt->SetPassEvent();
2065 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2080 commit.
Push(
_(
"Move Footprint Anchor" ) );
2091 else if( evt->IsCancelInteractive() || evt->IsActivate() )
2098 evt->SetPassEvent();
2111#define TOGGLE( a ) a = !a
2143 std::optional<VECTOR2D> aStartingPoint,
2144 std::stack<PCB_SHAPE*>* aCommittedGraphics )
2146 SHAPE_T shape = ( *aGraphic )->GetShape();
2149 wxASSERT( shape == SHAPE_T::SEGMENT || shape == SHAPE_T::CIRCLE || shape == SHAPE_T::RECTANGLE );
2189 bool started =
false;
2190 bool cancelled =
false;
2208 if( !isLocalOriginSet )
2219 if( aStartingPoint )
2234 if( shape == SHAPE_T::RECTANGLE )
2235 is45Limited =
false;
2237 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2243 if( evt->IsCancelInteractive() || ( started && evt->IsAction( &
ACTIONS::undo ) ) )
2250 evt->SetPassEvent(
false );
2257 else if( evt->IsActivate() )
2259 if( evt->IsPointEditor() )
2263 else if( evt->IsMoveTool() )
2312 frame()->SetMsgPanel( graphic );
2316 evt->SetPassEvent();
2335 if( aStartingPoint )
2337 cursorPos = *aStartingPoint;
2338 aStartingPoint = std::nullopt;
2353 grid.SetSkipPoint( cursorPos );
2356 twoPointMgr.
SetEnd( cursorPos );
2358 if( !isLocalOriginSet )
2362 frame()->SetMsgPanel( graphic );
2380 if( shape == SHAPE_T::SEGMENT && snapItem && graphic->
GetLength() > 0 )
2385 commit.
Add( graphic );
2386 commit.
Push(
_(
"Draw Line" ) );
2399 twoPointMgr.
Reset();
2405 else if( evt->IsMotion() )
2407 VECTOR2I clampedCursorPos = cursorPos;
2409 if( shape == SHAPE_T::CIRCLE || shape == SHAPE_T::ARC )
2415 if( started && is45Limited )
2427 twoPointMgr.
SetEnd( clampedCursorPos );
2438 if( aCommittedGraphics && !aCommittedGraphics->empty() )
2440 twoPointMgr.
SetOrigin( aCommittedGraphics->top()->GetStart() );
2441 twoPointMgr.
SetEnd( aCommittedGraphics->top()->GetEnd() );
2442 aCommittedGraphics->pop();
2468 frame()->SetMsgPanel( graphic );
2477 frame()->SetMsgPanel( graphic );
2482 frame()->OnEditItemRequest( graphic );
2484 frame()->SetMsgPanel( graphic );
2493 isLocalOriginSet =
true;
2494 evt->SetPassEvent();
2500 userUnits =
frame()->GetUserUnits();
2501 twoPointAsst.
SetUnits( userUnits );
2504 evt->SetPassEvent();
2508 evt->SetPassEvent();
2512 if( !isLocalOriginSet )
2558 std::optional<VECTOR2D> aStartingPoint )
2560 wxCHECK( aGraphic,
false );
2564 wxCHECK( graphic,
false );
2600 *aGraphic =
nullptr;
2608 bool started =
false;
2609 bool cancelled =
false;
2613 if( aStartingPoint )
2628 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2634 if( evt->IsCancelInteractive() || ( started && evt->IsAction( &
ACTIONS::undo ) ) )
2641 evt->SetPassEvent(
false );
2648 else if( evt->IsActivate() )
2650 if( evt->IsPointEditor() )
2654 else if( evt->IsMoveTool() )
2669 else if( evt->IsClick(
BUT_LEFT ) )
2689 preview.
Add( graphic );
2690 frame()->SetMsgPanel( graphic );
2694 arcManager.
AddPoint( cursorPos,
true );
2700 else if( evt->IsMotion() )
2706 arcManager.
AddPoint( cursorPos,
false );
2729 frame()->SetMsgPanel( graphic );
2733 evt->SetPassEvent();
2741 frame()->OnEditItemRequest( graphic );
2743 frame()->SetMsgPanel( graphic );
2750 frame()->OnEditItemRequest( graphic );
2752 frame()->SetMsgPanel( graphic );
2757 evt->SetPassEvent();
2775 frame()->SetMsgPanel( graphic );
2788 frame()->SetMsgPanel( graphic );
2800 evt->SetPassEvent();
2809 evt->SetPassEvent();
2823 frame()->SetMsgPanel( graphic );
2829 preview.
Remove( graphic );
2868 std::unique_ptr<PCB_SHAPE> bezier = std::make_unique<PCB_SHAPE>(
m_frame->
GetModel() );
2869 bezier->SetShape( SHAPE_T::BEZIER );
2870 bezier->SetFlags(
IS_NEW );
2896 const auto setCursor = [&]()
2901 const auto resetProgress = [&]()
2912 const auto started = [&]()
2918 bool priming =
false;
2923 if( aStartingPoint )
2927 if( aStartingControl1Point )
2929 bezierManager.
AddPoint( *aStartingPoint,
true );
2930 bezierManager.
AddPoint( *aStartingControl1Point,
true );
2935 bezierManager.
AddPoint( *aStartingPoint,
true );
2950 bezier->SetShape( SHAPE_T::BEZIER );
2955 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2961 if( evt->IsCancelInteractive() || ( started() && evt->IsAction( &
ACTIONS::undo ) ) )
2968 evt->SetPassEvent(
false );
2981 else if( evt->IsActivate() )
2983 if( evt->IsPointEditor() )
2987 else if( evt->IsMoveTool() )
3017 frame()->SetMsgPanel( bezier.get() );
3021 bezierManager.
AddPoint( cursorPos,
true );
3025 const bool doubleClick = evt->IsDblClick(
BUT_LEFT );
3032 bezierManager.
AddPoint( cursorPos,
true );
3038 preview.
Add( bezier.get() );
3055 preview.
Remove( bezier.get() );
3058 else if( evt->IsMotion() )
3064 bezierManager.
AddPoint( cursorPos,
false );
3087 frame()->SetMsgPanel( bezier.get() );
3091 evt->SetPassEvent();
3099 frame()->OnEditItemRequest( bezier.get() );
3101 frame()->SetMsgPanel( bezier.get() );
3106 evt->SetPassEvent();
3124 frame()->SetMsgPanel( bezier.get() );
3137 frame()->SetMsgPanel( bezier.get() );
3145 evt->SetPassEvent();
3155 evt->SetPassEvent();
3170 frame()->SetMsgPanel( bezier.get() );
3176 preview.
Remove( bezier.get() );
3193 bool clearSelection =
false;
3197 if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
3205 clearSelection =
true;
3216 if( clearSelection )
3244 ZONE* sourceZone =
nullptr;
3255 params.
m_mode = zoneMode;
3259 if( zoneMode == ZONE_MODE::SIMILAR && !sourceZone->
IsOnLayer( params.
m_layer ) )
3266 bool started =
false;
3280 polyGeomMgr.
Reset();
3282 grid.ClearSkipPoint();
3305 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3316 if( evt->IsCancelInteractive() )
3327 evt->SetPassEvent(
false );
3331 else if( evt->IsActivate() )
3336 if( evt->IsPointEditor() )
3340 else if( evt->IsMoveTool() )
3353 if( zoneMode != ZONE_MODE::SIMILAR )
3375 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
3382 polyGeomMgr.
Reset();
3389 else if( polyGeomMgr.
AddPoint( cursorPos ) )
3412 cursorPos = last.value();
3422 else if( started && ( evt->IsMotion()
3448 evt->SetPassEvent();
3470 std::shared_ptr<DRC_ENGINE> m_drcEngine;
3472 int m_worstClearance;
3473 bool m_allowDRCViolations;
3480 m_worstClearance( 0 )
3498 m_worstClearance = std::max( m_worstClearance, constraint.
GetValue().
Min() );
3502 for(
PAD*
pad : footprint->Pads() )
3504 std::optional<int> padOverride =
pad->GetClearanceOverrides(
nullptr );
3506 if( padOverride.has_value() )
3507 m_worstClearance = std::max( m_worstClearance, padOverride.value() );
3516 virtual ~VIA_PLACER()
3526 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3528 std::vector<PCB_TRACK*> possible_tracks;
3530 wxCHECK( view,
nullptr );
3532 view->
Query( bbox, items );
3549 possible_tracks.push_back( track );
3557 possible_tracks.push_back( arc );
3562 int min_d = std::numeric_limits<int>::max();
3564 for(
PCB_TRACK* track : possible_tracks )
3566 SEG test( track->GetStart(), track->GetEnd() );
3567 int dist = (
test.NearestPoint( position ) - position ).EuclideanNorm();
3572 return_track = track;
3576 return return_track;
3584 ZONE* zone =
dynamic_cast<ZONE*
>( aOther );
3613 int connectedItemNet = connectedItem->
GetNetCode();
3615 if( connectedItemNet == 0 || connectedItemNet == aVia->
GetNetCode() )
3628 if( clearance >= 0 )
3633 if( viaShape->Collide( otherShape.get(), clearance - m_drcEpsilon ) )
3644 if( clearance >= 0 )
3649 clearance - m_drcEpsilon ) )
3659 bool checkDRCViolation(
PCB_VIA* aVia )
3661 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3662 std::set<BOARD_ITEM*> checkedItems;
3665 bbox.
Inflate( m_worstClearance );
3668 for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
3670 if( !it.first->IsBOARD_ITEM() )
3688 else if( checkedItems.count( item ) )
3693 if( hasDRCViolation( aVia, item ) )
3696 checkedItems.insert( item );
3713 for(
FOOTPRINT* fp : m_board->Footprints() )
3715 for(
PAD*
pad : fp->Pads() )
3717 if(
pad->HitTest( position ) && (
pad->GetLayerSet() & lset ).any() )
3733 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
3736 std::vector<PCB_SHAPE*> possible_shapes;
3738 view->
Query( bbox, items );
3752 possible_shapes.push_back( shape );
3757 int min_d = std::numeric_limits<int>::max();
3759 for(
PCB_SHAPE* shape : possible_shapes )
3761 int dist = ( shape->GetPosition() - position ).EuclideanNorm();
3766 return_shape = shape;
3770 return return_shape;
3773 std::optional<int> selectPossibleNetsByPopupMenu( std::set<int>& aNetcodeList )
3777 std::map<int, int> menuIDNetCodeMap;
3780 for(
int netcode : aNetcodeList )
3786 menuText = wxString::Format(
"%s\t",
3789 menuText = wxString::Format(
"&%d %s\t",
3799 menu.
Add( menuText, menuID, BITMAPS::INVALID_BITMAP );
3800 menuIDNetCodeMap[ menuID ] = netcode;
3810 int selectedNetCode = -1;
3811 bool cancelled =
false;
3817 evt->SetPassEvent();
3821 std::optional<int>
id = evt->GetCommandId();
3824 if(
id && ( *
id > 0 ) && ( *
id < menuID ) )
3826 selectedNetCode = menuIDNetCodeMap.at( *
id );
3841 return std::optional<int>();
3843 return selectedNetCode;
3846 std::optional<int> findStitchedZoneNet(
PCB_VIA* aVia )
3850 std::set<int> netcodeList;
3858 for(
ZONE* z : m_board->Zones() )
3862 if( z->HitTestFilledArea( m_frame->
GetActiveLayer(), position ) )
3863 netcodeList.insert( z->GetNetCode() );
3870 if( netcodeList.size() == 1 )
3871 return *netcodeList.begin();
3876 for(
ZONE* z : m_board->Zones() )
3880 if( z->IsOnLayer( layer ) )
3882 if( z->HitTestFilledArea( layer, position ) )
3883 netcodeList.insert( z->GetNetCode() );
3889 if( netcodeList.size() == 1 )
3890 return *netcodeList.begin();
3892 if( netcodeList.size() > 1 )
3895 return selectPossibleNetsByPopupMenu( netcodeList );
3911 if( settings->
tracks != MAGNETIC_OPTIONS::NO_EFFECT && m_gridHelper.
GetSnap() )
3915 SEG trackSeg( track->GetStart(), track->GetEnd() );
3923 if( settings->
pads != MAGNETIC_OPTIONS::NO_EFFECT && m_gridHelper.
GetSnap() )
3936 if( shape->IsFilled() )
3942 switch( shape->GetShape() )
3944 case SHAPE_T::SEGMENT:
3946 SEG seg( shape->GetStart(), shape->GetEnd() );
3954 if( ( shape->GetEnd() - position ).SquaredEuclideanNorm() <
3955 ( shape->GetStart() - position ).SquaredEuclideanNorm() )
3969 if( !shape->IsPolyShapeValid() )
3976 std::optional<SEG> nearestSeg;
3977 int minDist = std::numeric_limits<int>::max();
3986 int dist = seg.
Distance( position );
3988 if( dist < minDist )
4026 via->SetIsFree(
false );
4030 via->SetNetCode(
pad->GetNetCode() );
4031 via->SetIsFree(
false );
4035 std::optional<int> netcode = findStitchedZoneNet(
via );
4037 if( !netcode.has_value() )
4040 via->SetNetCode( netcode.value() );
4041 via->SetIsFree(
via->GetNetCode() > 0 );
4044 if( checkDRCViolation(
via ) )
4049 if( !m_allowDRCViolations )
4063 if( track && m_gridHelper.
GetSnap() )
4067 SEG trackSeg( trackStart, trackEnd );
4069 if( viaPos == trackStart || viaPos == trackEnd )
4083 newTrack->
SetEnd( trackEnd );
4084 aCommit.
Add( newTrack );
4090 std::unique_ptr<BOARD_ITEM> CreateItem()
override
4095 via->SetNetCode( 0 );
4098 if(
via->GetViaType() == VIATYPE::THROUGH )
4113 via->SetLayerPair( first_layer, last_layer );
4116 if(
via->GetViaType() == VIATYPE::MICROVIA )
4119 via->GetEffectiveNetClass()->GetuViaDiameter() );
4120 via->SetDrill(
via->GetEffectiveNetClass()->GetuViaDrill() );
4128 return std::unique_ptr<BOARD_ITEM>(
via );
4132 VIA_PLACER placer(
frame() );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
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
const FOOTPRINTS & Footprints() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr 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.
const VECTOR2I & GetBezierC2() const
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
void SetFilled(bool aFlag)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
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 SetBezierC1(const VECTOR2I &aPt)
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 SetMirrored(bool isMirrored)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
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.
Represents an assistant draw when interactively drawing a bezier on a canvas.
void SetUnits(EDA_UNITS aUnits)
Manage the construction of a bezier through a series of steps.
VECTOR2I GetControlC2() const
Get the coordinates of the arc end point.
VECTOR2I GetControlC1() const
VECTOR2I GetStart() const
< Get the center point of the arc (valid when state > SET_ORIGIN)
@ SET_END
Waiting to lock in the end point.
@ SET_START
Waiting to lock in the start point.
BEZIER_STEPS GetStep() const
Get the current step the manager is on (useful when drawing something depends on the current state)
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
bool IsBOARD_ITEM() const
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.
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()
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
const wxString & GetNetname() const
Container for NETINFO_ITEM elements, which are the nets.
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
NETINFO_ITEM * GetNetItem(int aNetCode) const
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
static TOOL_ACTION deleteLastPoint
static TOOL_ACTION toggleHV45Mode
static TOOL_ACTION drawRuleArea
static TOOL_ACTION changeDimensionArrows
Switch between dimension arrow directions.
static TOOL_ACTION drawBezier
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION setAnchor
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION drawCircle
static TOOL_ACTION 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 lengthTunerSettings
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
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Common, abstract interface for edit frames.
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
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.
DIM_ARROW_DIRECTION GetArrowDirection() const
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
void SetArrowDirection(const DIM_ARROW_DIRECTION &aDirection)
int GetArrowLength() const
virtual const VECTOR2I & GetEnd() const