55 using namespace std::placeholders;
60 bool aKicadFilesOnly =
false );
67 m_pickerItem( nullptr )
80 m_frame = getEditFrame<PCB_BASE_FRAME>();
97 static_cast<PCB_BASE_EDIT_FRAME*>(
m_frame )->CreateNewLibrary();
99 static_cast<PCB_BASE_EDIT_FRAME*>(
m_frame )->AddLibrary();
113 template<
class T>
void Flip( T& aValue )
123 Flip( opts.m_DisplayPcbTrackFill );
126 for(
auto track :
board()->Tracks() )
145 Flip( opts.m_ShowGlobalRatsnest );
147 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility(
LAYER_RATSNEST,
148 opts.m_ShowGlobalRatsnest );
153 Flip( opts.m_DisplayRatsnestLinesCurved );
168 Flip( opts.m_DisplayViaFill );
171 for(
auto track :
board()->Tracks() )
202 int nextMode = ( static_cast<int>( opts.m_ZoneDisplayMode ) + 1 ) % 3;
203 opts.m_ZoneDisplayMode = static_cast<ZONE_DISPLAY_MODE>( nextMode );
225 opts.m_ContrastModeDisplay =
240 switch( opts.m_ContrastModeDisplay )
277 if( layer < F_Cu || layer >
B_Cu )
280 while( startLayer != ++layer )
303 if( layer < F_Cu || layer >
B_Cu )
306 while( startLayer != --layer )
340 #define ALPHA_MIN 0.20 341 #define ALPHA_MAX 1.00 342 #define ALPHA_STEP 0.05 354 settings->SetColor( currentLayer, currentColor );
364 wxUpdateUIEvent
dummy;
365 static_cast<PCB_EDIT_FRAME*>(
m_frame )->OnUpdateLayerAlpha(
dummy );
384 settings->SetColor( currentLayer, currentColor );
394 wxUpdateUIEvent
dummy;
395 static_cast<PCB_BASE_FRAME*>(
m_frame )->OnUpdateLayerAlpha(
dummy );
438 [
this] (
const VECTOR2D& pt ) ->
bool 460 #define HITTEST_THRESHOLD_PIXELS 5 480 [
this] (
const VECTOR2D& aPosition ) ->
bool 487 statusPopup.
SetText(
_(
"Item locked." ) );
489 statusPopup.
Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
518 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
520 if( !selectionTool->
Selectable( collector[ i ] ) )
543 [
this] (
const int& aFinalState )
560 std::vector<BOARD_ITEM*>& aPastedItems )
566 for(
PAD* pad : aClipFootprint->
Pads() )
568 pad->SetParent( editorFootprint );
569 aPastedItems.push_back( pad );
572 aClipFootprint->
Pads().clear();
582 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
589 FP_TEXT* text = static_cast<FP_TEXT*>( item );
600 item->SetParent( editorFootprint );
601 aPastedItems.push_back( item );
608 zone->SetParent( editorFootprint );
609 aPastedItems.push_back( zone );
612 aClipFootprint->
Zones().clear();
616 group->SetParent( editorFootprint );
617 aPastedItems.push_back( group );
620 aClipFootprint->
Groups().clear();
640 if( isFootprintEditor )
657 switch( clipItem->
Type() )
661 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
663 if( isFootprintEditor )
666 std::vector<BOARD_ITEM*> pastedItems;
675 PCB_SHAPE* clipShape = static_cast<PCB_SHAPE*>( clipDrawItem );
679 static_cast<PCB_SHAPE*>( pastedShape )->SwapData( clipShape );
683 pastedShape->
SetParent( editorFootprint );
684 pastedItems.push_back( pastedShape );
688 PCB_TEXT* clipTextItem = static_cast<PCB_TEXT*>( clipDrawItem );
692 static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
693 static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
695 pastedTextItem->
SetParent( editorFootprint );
696 pastedItems.push_back( pastedTextItem );
717 FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
718 std::vector<BOARD_ITEM*> pastedItems;
720 if( isFootprintEditor )
723 delete clipFootprint;
728 pastedItems.push_back( clipFootprint );
770 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
773 bool doCopy = ( aItem->GetFlags() &
SKIP_STRUCT ) == 0;
776 aItem->SetFlags( aIsNew ?
IS_NEW : 0 );
788 if( aList.size() == 0 )
791 auto obj = aList.front();
805 aTarget.push_back( obj );
818 obj = idx < int(aList.size()-1) ? aList[++idx] :
nullptr;
827 bool isNew =
board() != aBoard;
828 std::vector<BOARD_ITEM*> items;
847 bool aAnchorAtOrigin )
859 const_cast<KIID&>( item->m_Uuid ) =
KIID();
866 switch( item->Type() )
886 static_cast<FOOTPRINT*>( item )->SetPath(
KIID_PATH() );
896 editTool->GetCurrentCommit()->Add( item );
898 editTool->GetCurrentCommit()->Added( item );
910 if( !item->GetParentGroup() || !
alg::contains( aItems, item->GetParentGroup() ) )
916 if( aAnchorAtOrigin )
965 std::map<wxString, wxString> oldProperties = brd->
GetProperties();
966 std::map<wxString, wxString> newProperties;
983 props[
"page_width"] = xbuf;
984 props[
"page_height"] = ybuf;
987 pi.
Load( fileName, brd, &props );
999 for(
const std::pair<const wxString, wxString>& prop : oldProperties )
1000 newProperties[ prop.first ] = prop.second;
1013 if( copperLayerCount > initialCopperLayerCount )
1018 enabledLayers |= initialEnabledLayers;
1029 wxCommandEvent
dummy;
1041 wxCommandEvent
dummy;
1068 msgItems.emplace_back(
MSG_PANEL_ITEM(
_(
"Selected Items" ), msg ) );
1071 else if(
auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>(
m_frame ) )
1085 msgItems.emplace_back(
MSG_PANEL_ITEM(
_(
"Footprint Name" ), msg ) );
1091 msg = date.Format( wxT(
"%b %d, %Y" ) );
1093 msg =
_(
"Unknown" );
1100 wxString doc, keyword;
static TOOL_ACTION selectionClear
Clear the current selection.
std::vector< ZONE * > ZONES
PCB_GROUP * GetParentGroup() const
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
static TOOL_ACTION layerBottom
static TOOL_ACTION layerInner26
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Undo the last edit:
Filled polygons are shown.
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
static const KICAD_T FootprintItems[]
A scan list for primary footprint items.
static const KICAD_T BoardLevelItems[]
A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT,...
int GridSetOrigin(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
const UTF8 & GetLibItemName() const
static TOOL_ACTION move
move or drag an item
class ALIGNED_DIMENSION, a linear dimension (graphic item)
void ForceRefresh()
Force a redraw.
static TOOL_ACTION layerNext
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
class LEADER, a leader dimension (graphic item)
static TOOL_ACTION layerInner2
class FP_TEXT, text in a footprint
wxPoint m_GridOrigin
origin for grid offsets
BOARD_ITEM * m_pickerItem
static NETINFO_ITEM * OrphanedItem()
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
int LayerAlphaDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner5
int GetUserUnits()
Returns the currently selected user unit value for the interface.
int Redo(const TOOL_EVENT &aEvent)
int LayerNext(const TOOL_EVENT &aEvent)
static const TOOL_EVENT UnselectedEvent
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void OnDisplayOptionsChanged()
This file is part of the common library.
#define ZONE_LAYER_FOR(copperLayer)
Macro for getting the zone layer for a given copper layer.
static TOOL_ACTION doDelete
PCB_BASE_FRAME * m_frame
Grid origin marker.
virtual void SetPosition(const wxPoint &aPos)
static TOOL_ACTION layerInner6
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
DIM_UNITS_MODE GetUnitsMode() const
static TOOL_ACTION layerInner7
static TOOL_ACTION layerInner8
void SetProperties(const std::map< wxString, wxString > &aProps)
Outlines of filled polygons are shown.
static TOOL_ACTION layerInner21
GROUPS & Groups()
The groups must maintain the following invariants.
int placeBoardItems(std::vector< BOARD_ITEM * > &aItems, bool aIsNew, bool aAnchorAtOrigin)
Add and select or just select for move/place command a list of board items.
static TOOL_ACTION ratsnestLineMode
A set of BOARD_ITEMs (i.e., without duplicates).
static TOOL_ACTION layerAlphaDec
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
static TOOL_ACTION gridResetOrigin
static TOOL_ACTION zoneDisplayOutlines
int LayerAlphaInc(const TOOL_EVENT &aEvent)
class CENTER_DIMENSION, a center point marking (graphic item)
void SetTextAngle(double aAngle) override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Rebuild GAL display lists.
static TOOL_ACTION layerAlphaInc
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
static TOOL_ACTION zoneDisplayDisable
void SetCopperLayerCount(int aCount)
class PCB_TEXT, text on a layer
class ARC, an arc track segment on a copper layer
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
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.
class FP_SHAPE, a footprint edge
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void SetUnits(EDA_UNITS aUnits)
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
virtual wxPoint GetPosition() const
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
A name/value tuple with unique names and optional values.
static TOOL_ACTION layerInner3
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
static TOOL_ACTION layerInner24
static TOOL_ACTION layerInner11
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
virtual BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PLUGIN implementation knows about into either ...
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
virtual void SetParent(EDA_ITEM *aParent)
class TRACK, a track segment (segment on a copper layer)
virtual void Add(EDA_ITEM *aItem)
static TOOL_ACTION layerTop
static TOOL_ACTION pickerTool
int Undo(const TOOL_EVENT &aEvent)
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
virtual PCB_LAYER_ID GetActiveLayer() const
#define HITTEST_THRESHOLD_PIXELS
const std::map< wxString, wxString > & GetProperties() const
static TOOL_ACTION layerInner23
void setTransitions() override
< Sets up handlers for various events.
int GetCount() const
Return the number of objects in the list.
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
void SetReferencePoint(const VECTOR2I &aP)
static TOOL_ACTION appendBoard
static TOOL_ACTION zoneDisplayToggle
Non-active layers are dimmed (old high-contrast mode)
PCB_LAYER_ID
A quick note on layer IDs:
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...
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
LSET is a set of PCB_LAYER_IDs.
static TOOL_ACTION layerInner13
void SetFlags(STATUS_FLAGS aMask)
static TOOL_ACTION layerPrev
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
VECTOR2< double > VECTOR2D
virtual const wxString What() const
A composite of Problem() and Where()
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
TEXT_TYPE GetType() const
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
static TOOL_ACTION layerInner25
static TOOL_ACTION layerInner18
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
FOOTPRINTS & Footprints()
Non-active layers are shown normally (no high-contrast mode)
static TOOL_ACTION layerInner30
int GridResetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner29
int DeleteItemCursor(const TOOL_EVENT &aEvent)
static TOOL_ACTION showRatsnest
static TOOL_ACTION addLibrary
PCB_LAYER_ID m_Route_Layer_BOTTOM
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
static TOOL_ACTION layerInner10
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
NETCLASSES & GetNetClasses() const
ZONE handles a list of polygons defining a copper zone.
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
static void moveUnflaggedItems(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
virtual COLOR4D GetGridColor()
int HighContrastMode(const TOOL_EVENT &aEvent)
class DIMENSION_BASE: abstract dimension meta-type
static TOOL_ACTION layerInner15
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
static TOOL_ACTION newLibrary
static TOOL_ACTION layerInner28
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static TOOL_ACTION layerInner27
void UpdateColors()
Update the color settings in the painter and GAL.
int LAYER_NUM
This can be replaced with int and removed.
static TOOL_ACTION layerInner17
class FOOTPRINT, a footprint
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
static TOOL_ACTION layerInner20
virtual unsigned int GetSize() const override
Return the number of stored items.
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 viaDisplayMode
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
int Quit(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner22
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
int LayerSwitch(const TOOL_EVENT &aEvent)
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
virtual bool IsLocked() const
int Print(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int AppendBoard(PLUGIN &pi, wxString &fileName)
void Clear()
Destroy any contained NETCLASS instances except the default one, and clears any members from the defa...
Declaration of the eda_3d_viewer class.
static void pasteFootprintItemsToFootprintEditor(FOOTPRINT *aClipFootprint, BOARD *aBoard, std::vector< BOARD_ITEM * > &aPastedItems)
bool IsType(FRAME_T aType) const
Common, abstract interface for edit frames.
Only the zone outline is shown.
bool AskLoadBoardFileName(PCB_EDIT_FRAME *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly=false)
Show a wxFileDialog asking for a BOARD filename to open.
Information pertinent to a Pcbnew printed circuit board.
int FlipPcbView(const TOOL_EVENT &aEvent)
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Return a PLUGIN which the caller can use to import, export, save, or load design documents.
Used when the right click button is pressed, or when the select tool is in effect.
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
A base class that BOARD loading and saving plugins should derive from.
static TOOL_ACTION layerInner14
static TOOL_ACTION layerInner9
int HighContrastModeCycle(const TOOL_EVENT &aEvent)
int GetCopperLayerCount() const
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
The main frame for Pcbnew.
int Size() const
Returns the number of selected parts.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
A base class for most all the KiCad significant classes used in schematics and boards.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
static TOOL_ACTION layerInner16
int AddLibrary(const TOOL_EVENT &aEvent)
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
int LayerPrev(const TOOL_EVENT &aEvent)
static TOOL_ACTION deleteTool
static TOOL_ACTION highContrastModeCycle
void SetLocalCoord()
Set relative coordinates from draw coordinates.
static TOOL_ACTION layerInner4
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
class VIA, a via (like a track segment on a copper layer)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
int ToggleRatsnest(const TOOL_EVENT &aEvent)
Non-active layers are hidden.
static TOOL_ACTION flipBoard
static TOOL_ACTION gridSetOrigin
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
#define SKIP_STRUCT
flag indicating that the structure should be ignored
A general implementation of a COLLECTORS_GUIDE.
static TOOL_ACTION layerInner19
int LayerToggle(const TOOL_EVENT &aEvent)
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
static TOOL_ACTION layerInner1
class PCB_SHAPE, a segment not on copper layers
static TOOL_ACTION highContrastMode
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
#define IS_NEW
New item, just created.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
FP_ZONE is a specialization of ZONE for use in footprints.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
void MarkDirty()
Force redraw of view on the next rendering.
static TOOL_ACTION trackDisplayMode
PCB_LAYER_ID m_Route_Layer_TOP
int TrackDisplayMode(const TOOL_EVENT &aEvent)
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
void DisplayToolMsg(const wxString &msg) override
static TOOL_ACTION layerInner12
KICAD_T Type() const
Returns the type of object.
IO_MGR::PCB_FILE_T plugin_type(const wxString &aFileName, int aCtl)
Position or shape has changed.
static TOOL_ACTION layerToggle
A color representation with 4 components: red, green, blue, alpha.
static TOOL_ACTION zoneDisplayEnable
int ViaDisplayMode(const TOOL_EVENT &aEvent)