33#include <dialogs/dialog_text_properties.h>
52#include <wx/filedlg.h>
109 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
118 if(
via.m_Drill > 0 )
120 msg.Printf(
_(
"Via %s, hole %s" ),
126 msg.Printf(
_(
"Via %s" ),
131 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
140 int id = aEvent.GetId();
149 if( sizeDlg.ShowModal() == wxID_OK )
170 m_controls( nullptr ),
174 m_inDrawingTool( false ),
196 auto activeToolFunctor =
213 auto canCloseOutline =
250 std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
251 viaSizeMenu->SetTool(
this );
253 ctxMenu.
AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
261 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus(
m_menu );
273 m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
316 std::optional<VECTOR2D> startingPoint;
327 while(
drawShape( aEvent, &line, startingPoint ) )
332 static_cast<FP_SHAPE*
>( line )->SetLocalCoord();
335 commit.
Push(
_(
"Draw a line segment" ) );
340 startingPoint = std::nullopt;
366 std::optional<VECTOR2D> startingPoint;
378 return new FP_SHAPE( parentFootprint );
400 while(
drawShape( aEvent, &rect, startingPoint ) )
405 static_cast<FP_SHAPE*
>( rect )->SetLocalCoord();
416 commit.
Push( isTextBox ?
_(
"Draw a text box" ) :
_(
"Draw a rectangle" ) );
426 startingPoint = std::nullopt;
447 std::optional<VECTOR2D> startingPoint;
459 while(
drawShape( aEvent, &circle, startingPoint ) )
464 static_cast<FP_SHAPE*
>( circle )->SetLocalCoord();
466 commit.
Add( circle );
467 commit.
Push(
_(
"Draw a circle" ) );
477 startingPoint = std::nullopt;
498 std::optional<VECTOR2D> startingPoint;
509 while(
drawArc( aEvent, &arc, startingPoint ) )
514 static_cast<FP_SHAPE*
>( arc )->SetLocalCoord();
517 commit.
Push(
_(
"Draw an arc" ) );
526 startingPoint = std::nullopt;
541 bool immediateMode =
image !=
nullptr;
543 bool ignorePrimePosition =
false;
555 image->SetPosition( cursorPos );
599 ignorePrimePosition =
true;
608 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
614 if( evt->IsCancelInteractive() )
632 else if( evt->IsActivate() )
634 if(
image && evt->IsMoveTool() )
637 evt->SetPassEvent(
false );
644 evt->SetPassEvent(
false );
648 if( evt->IsMoveTool() )
665 wxFileDialog dlg(
m_frame,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
666 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
669 if( dlg.ShowModal() != wxID_OK )
675 if( evt->IsPrime() && !ignorePrimePosition )
677 cursorPos =
grid.Align( evt->Position() );
688 wxString fullFilename = dlg.GetPath();
690 if( wxFileExists( fullFilename ) )
693 if( !
image || !
image->ReadImageFile( fullFilename ) )
695 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
716 commit.Push(
_(
"Place an image" ) );
742 image->SetPosition( cursorPos );
785 bool ignorePrimePosition =
false;
831 ignorePrimePosition =
true;
840 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
846 if( evt->IsCancelInteractive() )
858 else if( evt->IsActivate() )
863 if( evt->IsMoveTool() )
880 bool placing =
text !=
nullptr;
916 cancelled = !textDialog.ShowModal();
973 commit.
Push(
_(
"Place a text" ) );
985 if( evt->IsPrime() && !ignorePrimePosition )
987 cursorPos = evt->Position();
1004 text->SetPosition( cursorPos );
1022 evt->SetPassEvent();
1027 evt->SetPassEvent();
1062 enum DIMENSION_STEPS
1077 int step = SET_ORIGIN;
1093 dimension =
nullptr;
1122 if( step > SET_ORIGIN )
1128 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1130 if( step == SET_HEIGHT )
1136 grid.SetUseGrid(
false );
1145 if( evt->IsCancelInteractive() )
1149 if( step != SET_ORIGIN )
1159 else if( evt->IsActivate() )
1161 if( step != SET_ORIGIN )
1164 if( evt->IsPointEditor() )
1168 else if( evt->IsMoveTool() )
1211 auto setMeasurementAttributes =
1230 setMeasurementAttributes( dimension );
1235 setMeasurementAttributes( dimension );
1244 setMeasurementAttributes( dimension );
1253 wxFAIL_MSG( wxT(
"Unhandled action in DRAWING_TOOL::DrawDimension" ) );
1256 t = dimension->
Type();
1266 dimension->
SetEnd( cursorPos );
1275 preview.
Add( dimension );
1307 preview.
Remove( dimension );
1309 commit.
Add( dimension );
1310 commit.
Push(
_(
"Draw a dimension" ) );
1323 if( ++step >= FINISHED )
1325 dimension =
nullptr;
1330 else if( evt->IsDblClick(
BUT_LEFT ) )
1335 else if( evt->IsMotion() )
1340 dimension->
SetEnd( cursorPos );
1364 textOffset = -textOffset;
1373 textOffset = -textOffset;
1428 ortho->SetHeight( vert ? heightVector.
x : heightVector.
y );
1460 if( step == SET_END || step == SET_HEIGHT )
1478 evt->SetPassEvent();
1482 if( step != SET_ORIGIN )
1512 int dlgResult = dlg.ShowModal();
1516 if( dlgResult != wxID_OK )
1522 wxMessageBox(
_(
"No graphic items found in file.") );
1528 std::vector<BOARD_ITEM*> newItems;
1529 std::vector<BOARD_ITEM*> selectedItems;
1542 newItems.push_back(
group );
1543 selectedItems.push_back(
group );
1547 for( std::unique_ptr<EDA_ITEM>& ptr : list )
1556 newItems.push_back( item );
1559 group->AddItem( item );
1561 selectedItems.push_back( item );
1563 preview.
Add( item );
1573 commit.
Push(
_(
"Place a DXF_SVG drawing" ) );
1577 layer = newItems.front()->GetLayer();
1608 item->Move(
delta );
1618 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1624 if( evt->IsCancelInteractive() || evt->IsActivate() )
1639 else if( evt->IsMotion() )
1644 item->Move(
delta );
1658 commit.
Push(
_(
"Place a DXF_SVG drawing" ) );
1667 evt->SetPassEvent();
1722 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1737 commit.
Push(
_(
"Move the footprint reference anchor" ) );
1748 else if( evt->IsCancelInteractive() || evt->IsActivate() )
1755 evt->SetPassEvent();
1768#define TOGGLE( a ) a = !a
1800 std::optional<VECTOR2D> aStartingPoint )
1802 SHAPE_T shape = ( *aGraphic )->GetShape();
1842 bool started =
false;
1843 bool cancelled =
false;
1861 if( !isLocalOriginSet )
1872 if( aStartingPoint )
1884 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1890 if( evt->IsCancelInteractive() )
1897 evt->SetPassEvent(
false );
1904 else if( evt->IsActivate() )
1906 if( evt->IsPointEditor() )
1910 else if( evt->IsMoveTool() )
1965 evt->SetPassEvent();
1981 if( aStartingPoint )
1983 cursorPos = *aStartingPoint;
1984 aStartingPoint = std::nullopt;
2001 grid.SetSkipPoint( cursorPos );
2004 twoPointManager.
SetEnd( cursorPos );
2006 if( !isLocalOriginSet )
2009 preview.
Add( graphic );
2028 twoPointManager.
Reset();
2033 PCB_SHAPE* snapItem = dyn_cast<PCB_SHAPE*>(
grid.GetSnapped() );
2047 commit.
Add( graphic );
2048 commit.
Push(
_(
"Draw a line segment" ) );
2060 twoPointManager.
Reset();
2066 else if( evt->IsMotion() )
2068 VECTOR2I clampedCursorPos = cursorPos;
2083 const VECTOR2I lineVector( clampedCursorPos
2094 twoPointManager.
SetEnd( clampedCursorPos );
2132 isLocalOriginSet =
true;
2133 evt->SetPassEvent();
2140 twoPointAsst.
SetUnits( userUnits );
2143 evt->SetPassEvent();
2147 evt->SetPassEvent();
2151 if( !isLocalOriginSet )
2197 std::optional<VECTOR2D> aStartingPoint )
2199 wxCHECK( aGraphic,
false );
2203 wxCHECK( graphic,
false );
2236 *aGraphic =
nullptr;
2244 bool started =
false;
2245 bool cancelled =
false;
2249 if( aStartingPoint )
2263 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2268 if( evt->IsCancelInteractive() )
2275 evt->SetPassEvent(
false );
2282 else if( evt->IsActivate() )
2284 if( evt->IsPointEditor() )
2288 else if( evt->IsMoveTool() )
2303 else if( evt->IsClick(
BUT_LEFT ) )
2323 preview.
Add( graphic );
2328 arcManager.
AddPoint( cursorPos,
true );
2334 else if( evt->IsMotion() )
2340 arcManager.
AddPoint( cursorPos,
false );
2367 evt->SetPassEvent();
2391 evt->SetPassEvent();
2423 evt->SetPassEvent();
2431 evt->SetPassEvent();
2451 preview.
Remove( graphic );
2469 bool clearSelection =
false;
2481 clearSelection =
true;
2487 *aZone = dyn_cast<ZONE*>(
selection[0] );
2492 if( clearSelection )
2520 ZONE* sourceZone =
nullptr;
2531 params.
m_mode = zoneMode;
2543 bool started =
false;
2557 polyGeomMgr.
Reset();
2559 grid.ClearSkipPoint();
2581 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2591 if( evt->IsCancelInteractive() )
2600 evt->SetPassEvent(
false );
2605 else if( evt->IsActivate() )
2610 if( evt->IsPointEditor() )
2614 else if( evt->IsMoveTool() )
2646 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
2653 polyGeomMgr.
Reset();
2660 else if( polyGeomMgr.
AddPoint( cursorPos ) )
2693 && ( evt->IsMotion() || evt->IsDrag(
BUT_LEFT ) ) )
2717 evt->SetPassEvent();
2739 std::shared_ptr<DRC_ENGINE> m_drcEngine;
2741 int m_worstClearance;
2742 bool m_allowDRCViolations;
2749 m_worstClearance( 0 )
2765 m_worstClearance = std::max( m_worstClearance, constraint.
GetValue().
Min() );
2770 m_worstClearance = std::max( m_worstClearance,
pad->GetLocalClearance() );
2778 virtual ~VIA_PLACER()
2788 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
2790 std::vector<PCB_TRACK*> possible_tracks;
2801 if(
PCB_TRACK* track = dyn_cast<PCB_TRACK*>( item ) )
2803 if(
TestSegmentHit( position, track->GetStart(), track->GetEnd(),
2804 ( track->GetWidth() + aVia->
GetWidth() ) / 2 ) )
2806 possible_tracks.push_back( track );
2812 int min_d = std::numeric_limits<int>::max();
2814 for(
PCB_TRACK* track : possible_tracks )
2816 SEG test( track->GetStart(), track->GetEnd() );
2822 return_track = track;
2826 return return_track;
2834 ZONE* zone =
dynamic_cast<ZONE*
>( aOther );
2846 int connectedItemNet = connectedItem->
GetNetCode();
2848 if( connectedItemNet == 0 || connectedItemNet == aVia->
GetNetCode() )
2860 if( clearance >= 0 )
2865 if( viaShape->Collide( otherShape.get(), clearance - m_drcEpsilon ) )
2876 if( clearance >= 0 )
2881 clearance - m_drcEpsilon ) )
2891 bool checkDRCViolation(
PCB_VIA* aVia )
2893 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
2894 std::set<BOARD_ITEM*> checkedItems;
2897 bbox.
Inflate( m_worstClearance );
2900 for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
2908 && !
static_cast<ZONE*
>( item )->GetIsRuleArea() )
2917 && !
static_cast<FP_TEXT*
>( item )->IsVisible() )
2921 else if( checkedItems.count( item ) )
2926 if( hasDRCViolation( aVia, item ) )
2929 checkedItems.insert( item );
2948 for(
PAD*
pad : fp->Pads() )
2950 if(
pad->HitTest( position ) && (
pad->GetLayerSet() & lset ).any() )
2952 if(
pad->GetNetCode() > 0 )
2961 int findStitchedZoneNet(
PCB_VIA* aVia )
2974 return z->GetNetCode();
2984 if( z->IsOnLayer( layer ) )
2986 if( z->HitTestFilledArea( layer, position ) )
2987 return z->GetNetCode();
3037 via->SetIsFree(
false );
3041 via->SetNetCode(
pad->GetNetCode() );
3042 via->SetIsFree(
false );
3046 via->SetNetCode( findStitchedZoneNet(
via ) );
3047 via->SetIsFree(
via->GetNetCode() > 0 );
3050 if( checkDRCViolation(
via ) )
3055 if( !m_allowDRCViolations )
3069 if( track && m_gridHelper.
GetSnap() )
3073 SEG trackSeg( trackStart, trackEnd );
3078 auto insertChevron =
3081 if( ( trackStart - *joint1 ).SquaredEuclideanNorm()
3082 > ( trackStart - *joint2 ).SquaredEuclideanNorm() )
3084 std::swap( joint1, joint2 );
3089 track->
SetEnd( *joint1 );
3092 wxCHECK( newTrack, );
3096 newTrack->
SetEnd( viaPos );
3097 aCommit.
Add( newTrack );
3100 wxCHECK( newTrack, );
3104 newTrack->
SetEnd( *joint2 );
3105 aCommit.
Add( newTrack );
3108 wxCHECK( newTrack, );
3112 newTrack->
SetEnd( trackEnd );
3113 aCommit.
Add( newTrack );
3116 if( viaPos == trackStart || viaPos == trackEnd )
3119 if( trackStart.
x == trackEnd.
x )
3123 if( splitPt.
x != viaPos.
x
3124 &&
abs( splitPt.
x - viaPos.
x ) <
abs( splitPt.
y - trackStart.
y )
3125 &&
abs( splitPt.
x - viaPos.
x ) <
abs( splitPt.
y - trackEnd.
y ) )
3127 int offset =
abs( splitPt.
x - viaPos.
x );
3129 joint1 =
VECTOR2I( splitPt.
x, splitPt.
y - offset );
3130 joint2 =
VECTOR2I( splitPt.
x, splitPt.
y + offset );
3136 else if( trackStart.
y == trackEnd.
y )
3140 if( splitPt.
y != viaPos.
y
3141 &&
abs( trackStart.
y - viaPos.
y ) <
abs( trackStart.
x - viaPos.
x )
3142 &&
abs( trackEnd.
y - viaPos.
y ) <
abs( trackEnd.
x - viaPos.
x ) )
3144 int offset =
abs( splitPt.
y - viaPos.
y );
3146 joint1 =
VECTOR2I( splitPt.
x - offset, splitPt.
y );
3147 joint2 =
VECTOR2I( splitPt.
x + offset, splitPt.
y );
3153 else if(
abs( trackStart.
y - trackEnd.
y ) ==
abs( trackStart.
x - trackEnd.
x ) )
3160 joint1 = trackSeg.
Intersect( horiz,
true,
true );
3161 joint2 = trackSeg.
Intersect( vert,
true,
true );
3163 if( !joint1 || !joint2 )
3179 newTrack->
SetEnd( trackEnd );
3180 aCommit.
Add( newTrack );
3186 std::unique_ptr<BOARD_ITEM> CreateItem()
override
3191 via->SetNetCode( 0 );
3212 switch(
via->GetViaType() )
3215 via->SetLayerPair( first_layer, last_layer );
3223 if( first_layer ==
B_Cu )
3224 last_layer = last_inner_layer;
3225 else if( first_layer ==
F_Cu )
3227 else if( first_layer == last_inner_layer )
3229 else if( first_layer ==
In1_Cu )
3233 via->SetLayerPair( first_layer, last_layer );
3247 return std::unique_ptr<BOARD_ITEM>(
via );
3251 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=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
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.
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
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 m_DimensionPrecision
Number of digits after the decimal.
int GetDRCEpsilon() const
unsigned GetViaSizeIndex() const
bool m_DimensionKeepTextAligned
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 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
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
FOOTPRINTS & Footprints()
int GetCopperLayerCount() const
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)
Create an undo entry for an item that has been already modified.
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
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...
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
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual void SetPosition(const VECTOR2I &aPos)
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
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)
double GetLength() const
Return the length of the track using the hypotenuse calculation.
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
const VECTOR2I & GetTextPos() const
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
void SetTextPos(const VECTOR2I &aPoint)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetTextSize(const VECTOR2I &aNewSize)
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 AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
void RecacheAllItems()
Rebuild GAL display lists.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
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
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 drawCircle
static TOOL_ACTION placeImage
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
static TOOL_ACTION trackViaSizeChanged
static TOOL_ACTION layerChanged
static TOOL_ACTION drawTextBox
static TOOL_ACTION drawZoneCutout
static TOOL_ACTION drawPolygon
static TOOL_ACTION drawRadialDimension
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 incWidth
Increase width of currently drawn line.
static TOOL_ACTION clearHighlight
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 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.
int ShowTextBoxPropertiesDialog(BOARD_ITEM *aText)
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
APPEARANCE_CONTROLS * GetAppearancePanel()
void SetObjectVisible(GAL_LAYER_ID aLayer, bool aVisible=true)
void ShowTextPropertiesDialog(BOARD_ITEM *aText)
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
Object to handle a bitmap image that can be inserted in a PCB.
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
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
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.
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).
PCB_LAYER_ID m_Route_Layer_TOP
PCB_LAYER_ID m_Route_Layer_BOTTOM
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
void SetStroke(const STROKE_PARAMS &aStroke) override
virtual 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.
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.
void DeleteLastCorner()
Remove the last-added point from the polygon.
bool NewPointClosesOutline(const VECTOR2I &aPt) const
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.
bool IsPolygonInProgress() const
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.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
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(bool aLoadNow=true)
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 SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
bool m_KeepUpright
If true, keep rotation angle between -90...90 degrees for readability.
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)
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
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
SHAPE_POLY_SET * Outline()
This file is part of the common library.
@ HOLE_CLEARANCE_CONSTRAINT
static constexpr EDA_ANGLE & ANGLE_90
static constexpr EDA_ANGLE & ANGLE_0
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
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 ...
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
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.
@ 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.
PLOT_DASH_TYPE
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_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ 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_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ 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_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< double > VECTOR2D