68 using namespace std::placeholders;
78 SetTitle(
_(
"Zones" ) );
109 SetTitle(
_(
"Locking" ) );
139 m_frame = getEditFrame<PCB_EDIT_FRAME>();
143 m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
152 auto activeToolCondition =
158 auto inactiveStateCondition =
164 auto placeModuleCondition =
174 ctxMenu.AddSeparator( 1 );
178 ctxMenu.AddSeparator( 1000 );
181 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus(
m_menu );
183 auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
184 zoneMenu->SetTool(
this );
186 auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
187 lockMenu->SetTool(
this );
196 auto& menu = toolMenu.
GetMenu();
202 toolMenu.AddSubMenu( zoneMenu );
203 toolMenu.AddSubMenu( lockMenu );
215 auto& menu = toolMenu.
GetMenu();
217 toolMenu.AddSubMenu( zoneMenu );
284 if( dlg.ShowModal() != wxID_OK )
300 getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
307 getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
319 wxFileName::SplitPath( fullFileName, &path, &
name, &ext );
320 name += wxT(
".ses" );
323 wxT(
".ses" ), wxT(
"*.ses" ),
frame(), wxFD_OPEN,
false );
325 if( !fullFileName.IsEmpty() )
326 getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
337 if( fullFileName.IsEmpty() )
345 fullFileName =
EDA_FILE_SELECTOR(
_(
"Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
347 frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
349 if( !fullFileName.IsEmpty() )
352 getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
361 wxCommandEvent
dummy;
372 wxFAIL_MSG(
"GenerateFabFiles(): unexpected request" );
393 if( ids.count( aItem->m_Uuid ) )
396 const_cast<KIID&>( aItem->m_Uuid ) =
KIID();
399 ids.insert( aItem->m_Uuid );
434 processItem( track );
450 processItem( group );
454 processItem( drawing );
460 processItem( marker );
463 processItem( group );
467 errors += duplicates;
483 wxString msg =
wxString::Format(
_(
"%d potential problems repaired." ), errors );
503 updateDialog.ShowModal();
514 m_frame,
_(
"Cannot update schematic because Pcbnew is opened in stand-alone " 515 "mode. In order to create or update PCBs from schematics, you " 516 "must launch the KiCad project manager and create a project." ) );
541 getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
548 #if defined( KICAD_SCRIPTING_WXPYTHON ) 549 m_frame->ScriptingConsoleEnableDisable();
584 commit.
Push(
"Increase Track Width" );
642 if( candidate < track->GetWidth() )
652 commit.
Push(
"Decrease Track Width" );
719 commit.
Push(
"Increase Via Size" );
770 commit.
Push(
"Decrease Via Size" );
811 bool reselect =
false;
812 bool fromOtherCommand = fp !=
nullptr;
848 if( fromOtherCommand )
863 if( evt->IsCancelInteractive() )
873 else if( evt->IsActivate() )
878 if( evt->IsMoveTool() )
912 pad->SetNetCode( 0 );
930 commit.
Push(
_(
"Place a footprint" ) );
999 BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1009 bool modified =
false;
1013 BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1015 commit.
Modify( board_item );
1019 modified |= !board_item->
IsLocked();
1024 modified |= board_item->
IsLocked();
1031 commit.
Push( aMode ==
ON ?
_(
"Lock" ) :
_(
"Unlock" ) );
1056 preview.
Add( target );
1080 if( evt->IsCancelInteractive() )
1085 else if( evt->IsActivate() )
1087 if( evt->IsMoveTool() )
1113 else if( evt->IsClick(
BUT_LEFT ) )
1115 assert( target->
GetSize() > 0 );
1119 commit.Add( target );
1120 commit.Push(
"Place a layer alignment target" );
1122 preview.
Remove( target );
1126 preview.
Add( target );
1132 else if( evt->IsMotion() )
1139 evt->SetPassEvent();
1153 std::vector<ZONE*>& aMergedZones )
1155 aCommit.
Modify( aOriginZones[0] );
1157 for(
unsigned int i = 1; i < aOriginZones.size(); i++ )
1159 aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
1169 if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
1171 wxLogMessage(
"BOARD::mergeZones error: more than 2 polys after merging" );
1175 for(
unsigned int i = 1; i < aOriginZones.size(); i++ )
1177 aCommit.
Remove( aOriginZones[i] );
1180 aMergedZones.push_back( aOriginZones[0] );
1182 aOriginZones[0]->SetLocalFlags( 1 );
1183 aOriginZones[0]->HatchBorder();
1184 aOriginZones[0]->CacheTriangulation();
1201 ZONE* firstZone =
nullptr;
1202 std::vector<ZONE*> toMerge, merged;
1206 ZONE* curr_area = dynamic_cast<ZONE*>( item );
1212 firstZone = curr_area;
1231 toMerge.push_back( curr_area );
1238 commit.
Push(
"Merge zones" );
1240 for(
auto item : merged )
1264 zoneSettings << *oldZone;
1267 if( oldZone->GetIsRuleArea() )
1269 else if( oldZone->IsOnCopperLayer() )
1274 if( dialogResult != wxID_OK )
1280 std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1281 newZone->ClearSelected();
1287 if( oldZone->GetIsRuleArea() && ( oldZone->GetLayerSet() == zoneSettings.
m_Layers ) )
1289 else if( !oldZone->GetIsRuleArea() && zoneSettings.
m_Layers.test( oldZone->GetLayer() ) )
1292 commit.
Add( newZone.release() );
1293 commit.
Push(
_(
"Duplicate zone" ) );
1316 editor->LoadFootprintFromBoard( fp );
1318 editor->Show(
true );
1332 originViewItem->
SetPosition( (wxPoint) aPosition );
1347 [
this] (
const VECTOR2D& pt ) ->
bool int Open(const TOOL_EVENT &aEvent)
int LockSelected(const TOOL_EVENT &aEvent)
Unlock selected items.
static TOOL_ACTION selectionClear
Clear the current selection.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
static TOOL_ACTION toggleLock
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
void OnModify() override
Must be called after a board change to set the modified flag.
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
int New(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
static TOOL_ACTION generateGerbers
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
static TOOL_ACTION editFpInFpEditor
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library TODO brief description.
static TOOL_ACTION pageSettings
int TrackWidthInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION incWidth
Increase width of currently drawn line.
unsigned GetPriority() const
Function GetPriority.
static TOOL_ACTION drawSimilarZone
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
static TOOL_ACTION drillOrigin
bool Init() override
Init() is called once upon a registration of the tool.
FOOTPRINT * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Open a dialog to select a footprint.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
This file is part of the common library.
virtual void SetPosition(const wxPoint &aPos)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
static TOOL_ACTION zoneFillAll
static TOOL_ACTION viaSizeInc
std::vector< int > m_TrackWidthList
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
static constexpr double IU_PER_MM
Mock up a conversion function.
GROUPS & Groups()
The groups must maintain the following invariants.
A set of BOARD_ITEMs (i.e., without duplicates).
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
int Plot(const TOOL_EVENT &aEvent)
virtual void Revert() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
static TOOL_ACTION cancelInteractive
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
static TOOL_ACTION properties
Activation of the edit tool.
void SetWksFileName(const wxString &aFilename)
int GeneratePosFile(const TOOL_EVENT &aEvent)
void RecreateBOMFileFromBoard(wxCommandEvent &aEvent)
Create a BOM file from the current loaded board.
static TOOL_ACTION trackWidthDec
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
static TOOL_ACTION getAndPlace
Find an item and start moving.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
static TOOL_ACTION trackViaSizeChanged
static TOOL_ACTION showPythonConsole
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
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.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
static TOOL_ACTION showLayersManager
static TOOL_ACTION updatePcbFromSchematic
virtual void Clear()
Remove all the stored items from the group.
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
int ImportNetlist(const TOOL_EVENT &aEvent)
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
const wxString & GetFileName() const
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static TOOL_ACTION generateReportFile
static TOOL_ACTION zoneFill
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
int PageSettings(const TOOL_EVENT &aEvent)
search types array terminator (End Of Types)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
virtual void SetParent(EDA_ITEM *aParent)
static TOOL_ACTION generateD356File
class TRACK, a track segment (segment on a copper layer)
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
static TOOL_ACTION saveCopyAs
void SetWidth(int aWidth)
int modifyLockSelected(MODIFY_MODE aMode)
Set up handlers for various events.
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
static TOOL_ACTION pickerTool
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
static TOOL_ACTION trackWidthInc
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
void SetReferencePoint(const VECTOR2I &aP)
int DrillOrigin(const TOOL_EVENT &aEvent)
Low-level access (below undo) to setting the drill origin.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
void GenFootprintsReport(wxCommandEvent &event)
Call DoGenFootprintsReport to create a footprint report file.
static TOOL_ACTION updateSchematicFromPcb
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
int ViaSizeInc(const TOOL_EVENT &aEvent)
void SetFlags(STATUS_FLAGS aMask)
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
static TOOL_ACTION importNetlist
#define MAX_PAGE_SIZE_PCBNEW_MILS
int UnlockSelected(const TOOL_EVENT &aEvent)
Run the drill origin tool for setting the origin for drill and pick-and-place files.
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
unsigned GetViaSizeIndex() const
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
static const int WIDTH_STEP
How does line width change after one -/+ key press.
FOOTPRINTS & Footprints()
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SetPosition(const wxPoint &aPos) override
int BoardSetup(const TOOL_EVENT &aEvent)
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
static TOOL_ACTION zoneMerge
unsigned GetTrackWidthIndex() const
Definition of file extensions used in Kicad.
const wxString & GetNetname() const
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
Extend VIEW_ITEM by possibility of grouping items into a single object.
An interface for classes handling user events controlling the view behavior such as zooming,...
int SaveAs(const TOOL_EVENT &aEvent)
virtual void Remove(VIEW_ITEM *aItem)
Remove an item from the group.
int Save(const TOOL_EVENT &aEvent)
ZONE handles a list of polygons defining a copper zone.
class ZONE, a copper pour area
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
int RepairBoard(const TOOL_EVENT &aEvent)
void SetDiffPairIndex(unsigned aIndex)
A holder to handle information on schematic or board items.
static TOOL_ACTION showEeschema
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
static TOOL_ACTION generatePosFile
static TOOL_ACTION drawZoneCutout
MODIFY_MODE
< How to modify a property for selected items.
static TOOL_ACTION placeTarget
int ShowEeschema(const TOOL_EVENT &aEvent)
const std::string SpecctraDsnFileExtension
static TOOL_ACTION zoneUnfillAll
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
static TOOL_ACTION boardSetup
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
bool Empty() const
Checks if there is anything selected.
bool m_ShowGlobalRatsnest
static TOOL_ACTION zoneUnfill
ZONE_SETTINGS handles zones parameters.
static TOOL_ACTION importSpecctraSession
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
static TOOL_ACTION generateBOM
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
Handle the data for a net.
virtual bool IsLocked() const
int ZoneMerge(const TOOL_EVENT &aEvent)
Duplicate a zone onto a layer (prompts for new layer)
static TOOL_ACTION placeFootprint
static TOOL_ACTION exportSpecctraDSN
Common, abstract interface for edit frames.
static TOOL_ACTION saveAs
const BITMAP_OPAQUE locked_xpm[1]
void GenD356File(wxCommandEvent &event)
Information pertinent to a Pcbnew printed circuit board.
static TOOL_ACTION repairBoard
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
int PlaceFootprint(const TOOL_EVENT &aEvent)
Display a dialog to select a footprint to be added and allows the user to set its position.
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Lock selected items.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
PCBNEW_SETTINGS & Settings()
int Size() const
Returns the number of selected parts.
int TogglePythonConsole(const TOOL_EVENT &aEvent)
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
std::vector< VIA_DIMENSION > m_ViasDimensionsList
void SetWidth(int aWidth)
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
bool Files_io_from_id(int aId)
Read and write board files according to aId.
const BITMAP_OPAQUE add_zone_xpm[1]
wxString SpecctraDsnFileWildcard()
class VIA, a via (like a track segment on a copper layer)
unsigned GetDiffPairIndex() const
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int ViaSizeDec(const TOOL_EVENT &aEvent)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
int GenerateFabFiles(const TOOL_EVENT &aEvent)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
int TrackWidthDec(const TOOL_EVENT &aEvent)
static constexpr int Millimeter2iu(double mm)
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
static TOOL_ACTION viaSizeDec
#define IS_NEW
New item, just created.
wxPoint m_AuxOrigin
origin for plot exports
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
void MarkDirty()
Force redraw of view on the next rendering.
int PlaceTarget(const TOOL_EVENT &aEvent)
Allow user to place a layer alignment target.
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
static TOOL_ACTION refreshPreview
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
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 SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
static TOOL_ACTION generateDrillFiles
int SaveCopyAs(const TOOL_EVENT &aEvent)
Container for design settings for a BOARD object.
A color representation with 4 components: red, green, blue, alpha.