KiCad PCB EDA Suite
PCBNEW_CONTROL Class Reference

PCBNEW_CONTROL. More...

#include <pcbnew_control.h>

Inheritance diagram for PCBNEW_CONTROL:
PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 PCBNEW_CONTROL ()
 
 ~PCBNEW_CONTROL ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int AddLibrary (const TOOL_EVENT &aEvent)
 
int Print (const TOOL_EVENT &aEvent)
 
int Quit (const TOOL_EVENT &aEvent)
 
int ToggleRatsnest (const TOOL_EVENT &aEvent)
 
int ZoneDisplayMode (const TOOL_EVENT &aEvent)
 
int TrackDisplayMode (const TOOL_EVENT &aEvent)
 
int ViaDisplayMode (const TOOL_EVENT &aEvent)
 
int HighContrastMode (const TOOL_EVENT &aEvent)
 
int HighContrastModeCycle (const TOOL_EVENT &aEvent)
 
int LayerSwitch (const TOOL_EVENT &aEvent)
 
int LayerNext (const TOOL_EVENT &aEvent)
 
int LayerPrev (const TOOL_EVENT &aEvent)
 
int LayerToggle (const TOOL_EVENT &aEvent)
 
int LayerAlphaInc (const TOOL_EVENT &aEvent)
 
int LayerAlphaDec (const TOOL_EVENT &aEvent)
 
int GridSetOrigin (const TOOL_EVENT &aEvent)
 
int GridResetOrigin (const TOOL_EVENT &aEvent)
 
int Undo (const TOOL_EVENT &aEvent)
 
int Redo (const TOOL_EVENT &aEvent)
 
int DeleteItemCursor (const TOOL_EVENT &aEvent)
 
int Paste (const TOOL_EVENT &aEvent)
 
int AppendBoardFromFile (const TOOL_EVENT &aEvent)
 
int AppendBoard (PLUGIN &pi, wxString &fileName)
 
int UpdateMessagePanel (const TOOL_EVENT &aEvent)
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
virtual bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Member Functions

static void DoSetGridOrigin (KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

bool m_editModules
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

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. More...
 
int placeBoardItems (BOARD *aBoard, bool aAnchorAtOrigin)
 

Private Attributes

PCB_BASE_FRAMEm_frame
 

Pointer to the currently used edit frame.

More...
 
std::unique_ptr< KIGFX::ORIGIN_VIEWITEMm_gridOrigin
 

Grid origin marker.

More...
 
BOARD_ITEMm_pickerItem
 

Detailed Description

PCBNEW_CONTROL.

Handles actions that are shared between different frames in pcbnew.

Definition at line 44 of file pcbnew_control.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

Handle the rotate action in the loop by calling the item's rotate method.

IPO_FLIP 

Handle flip action in the loop by calling the item's flip method.

IPO_SINGLE_CLICK 

Create an item immediately on placement starting, otherwise show the pencil cursor until the item is created.

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 116 of file pcb_tool_base.h.

116  {
118  IPO_ROTATE = 0x01,
119 
121  IPO_FLIP = 0x02,
122 
125  IPO_SINGLE_CLICK = 0x04,
126 
128  IPO_REPEAT = 0x08
129  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 79 of file tool_base.h.

80  {
81  RUN,
82  MODEL_RELOAD,
83  GAL_SWITCH
84  };
Model changes (required full reload)
Definition: tool_base.h:82
Tool is invoked after being inactive.
Definition: tool_base.h:81
Rendering engine changes.
Definition: tool_base.h:83

Constructor & Destructor Documentation

◆ PCBNEW_CONTROL()

PCBNEW_CONTROL::PCBNEW_CONTROL ( )

Definition at line 62 of file pcbnew_control.cpp.

62  :
63  PCB_TOOL_BASE( "pcbnew.Control" ),
64  m_frame( nullptr ),
65  m_pickerItem( nullptr )
66 {
67  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
68 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
BOARD_ITEM * m_pickerItem
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:75

References m_gridOrigin.

◆ ~PCBNEW_CONTROL()

PCBNEW_CONTROL::~PCBNEW_CONTROL ( )

Definition at line 71 of file pcbnew_control.cpp.

72 {
73 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ AddLibrary()

int PCBNEW_CONTROL::AddLibrary ( const TOOL_EVENT aEvent)

Definition at line 90 of file pcbnew_control.cpp.

91 {
93  {
94  if( aEvent.IsAction( &ACTIONS::newLibrary ) )
95  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
96  else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
97  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
98  }
99 
100  return 0;
101 }
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION addLibrary
Definition: actions.h:52
static TOOL_ACTION newLibrary
Definition: actions.h:51
bool IsType(FRAME_T aType) const

References ACTIONS::addLibrary, FRAME_FOOTPRINT_EDITOR, FRAME_PCB_EDITOR, TOOL_EVENT::IsAction(), EDA_BASE_FRAME::IsType(), m_frame, and ACTIONS::newLibrary.

Referenced by setTransitions().

◆ AppendBoard()

int PCBNEW_CONTROL::AppendBoard ( PLUGIN pi,
wxString &  fileName 
)

Definition at line 901 of file pcbnew_control.cpp.

902 {
903  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
904 
905  if( !editFrame )
906  return 1;
907 
908  BOARD* brd = board();
909 
910  if( !brd )
911  return 1;
912 
913  // Mark existing items, in order to know what are the new items so we can select only
914  // the new items after loading
915  for( auto track : brd->Tracks() )
916  track->SetFlags( SKIP_STRUCT );
917 
918  for( auto module : brd->Modules() )
920 
921  for( auto group : brd->Groups() )
922  group->SetFlags( SKIP_STRUCT );
923 
924  for( auto drawing : brd->Drawings() )
925  drawing->SetFlags( SKIP_STRUCT );
926 
927  for( auto zone : brd->Zones() )
928  zone->SetFlags( SKIP_STRUCT );
929 
930  std::map<wxString, wxString> oldProperties = brd->GetProperties();
931  std::map<wxString, wxString> newProperties;
932 
933  // Keep also the count of copper layers, to adjust if necessary
934  int initialCopperLayerCount = brd->GetCopperLayerCount();
935  LSET initialEnabledLayers = brd->GetEnabledLayers();
936 
937  // Load the data
938  try
939  {
940  PROPERTIES props;
941  char xbuf[30];
942  char ybuf[30];
943 
944  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
945  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
946  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
947 
948  props["page_width"] = xbuf;
949  props["page_height"] = ybuf;
950 
951  editFrame->GetDesignSettings().GetNetClasses().Clear();
952  pi.Load( fileName, brd, &props );
953  }
954  catch( const IO_ERROR& ioe )
955  {
956  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
957  DisplayError( editFrame, msg );
958 
959  return 0;
960  }
961 
962  newProperties = brd->GetProperties();
963 
964  for( const std::pair<const wxString, wxString>& prop : oldProperties )
965  newProperties[ prop.first ] = prop.second;
966 
967  brd->SetProperties( newProperties );
968 
969  // rebuild nets and ratsnest before any use of nets
970  brd->BuildListOfNets();
972  brd->BuildConnectivity();
973 
974  // Synchronize layers
975  // we should not ask PLUGINs to do these items:
976  int copperLayerCount = brd->GetCopperLayerCount();
977 
978  if( copperLayerCount > initialCopperLayerCount )
979  brd->SetCopperLayerCount( copperLayerCount );
980 
981  // Enable all used layers, and make them visible:
982  LSET enabledLayers = brd->GetEnabledLayers();
983  enabledLayers |= initialEnabledLayers;
984  brd->SetEnabledLayers( enabledLayers );
985  brd->SetVisibleLayers( enabledLayers );
986 
987  return placeBoardItems( brd, false );
988 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
void BuildListOfNets()
Definition: class_board.h:663
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
BOARD * board() const
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: class_board.h:271
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: class_board.h:266
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
void SetCopperLayerCount(int aCount)
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
const std::map< wxString, wxString > & GetProperties() const
Definition: class_board.h:270
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
LSET is a set of PCB_LAYER_IDs.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
MODULES & Modules()
Definition: class_board.h:247
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
NETCLASSES & GetNetClasses() const
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
ZONE_CONTAINERS & Zones()
Definition: class_board.h:253
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one, and clears any membe...
Definition: netclass.h:237
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
int GetCopperLayerCount() const
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.
PCB_EDIT_FRAME is the main frame for Pcbnew.
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
DRAWINGS & Drawings()
Definition: class_board.h:250
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
TRACKS & Tracks()
Definition: class_board.h:244
virtual BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL)
Function Load loads information from some input file format that this PLUGIN implementation knows abo...
Definition: plugin.cpp:46

References _, PCB_TOOL_BASE::board(), BOARD::BuildConnectivity(), BOARD::BuildListOfNets(), NETCLASSES::Clear(), DisplayError(), BOARD::Drawings(), Format(), GetChars(), BOARD::GetCopperLayerCount(), PCB_BASE_FRAME::GetDesignSettings(), BOARD::GetEnabledLayers(), BOARD_DESIGN_SETTINGS::GetNetClasses(), PCB_BASE_FRAME::GetPageSizeIU(), BOARD::GetProperties(), BOARD::Groups(), PLUGIN::Load(), m_frame, PCB_TOOL_BASE::module(), BOARD::Modules(), placeBoardItems(), BOARD::SetCopperLayerCount(), BOARD::SetEnabledLayers(), EDA_ITEM::SetFlags(), BOARD::SetProperties(), BOARD::SetVisibleLayers(), SKIP_STRUCT, BOARD::SynchronizeNetsAndNetClasses(), BOARD::Tracks(), IO_ERROR::What(), and BOARD::Zones().

Referenced by AppendBoardFromFile().

◆ AppendBoardFromFile()

int PCBNEW_CONTROL::AppendBoardFromFile ( const TOOL_EVENT aEvent)

Definition at line 729 of file pcbnew_control.cpp.

730 {
731  int open_ctl;
732  wxString fileName;
733 
734  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
735 
736  if( !editFrame )
737  return 1;
738 
739  // Pick a file to append
740  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
741  return 1;
742 
743  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
744  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
745 
746  return AppendBoard( *pi, fileName );
747 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destructor.
Definition: io_mgr.h:580
bool AskLoadBoardFileName(wxWindow *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly=false)
Function AskLoadBoardFileName puts up a wxFileDialog asking for a BOARD filename to open.
IO_MGR::PCB_FILE_T plugin_type(const wxString &aFileName, int aCtl)
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Function PluginFind returns a PLUGIN which the caller can use to import, export, save,...
Definition: io_mgr.cpp:62
PCB_EDIT_FRAME is the main frame for Pcbnew.
PCB_FILE_T
Enum PCB_FILE_T is a set of file types that the IO_MGR knows about, and for which there has been a pl...
Definition: io_mgr.h:54
int AppendBoard(PLUGIN &pi, wxString &fileName)

References AppendBoard(), AskLoadBoardFileName(), m_frame, plugin_type(), and IO_MGR::PluginFind().

Referenced by setTransitions().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 166 of file pcb_tool_base.h.

166 { return getModel<BOARD>(); }

Referenced by AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), PCB_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER_TOOL::FillAllZones(), SELECTION_TOOL::FilterCollectorForGroups(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::GetBoard(), SELECTION_TOOL::getCollectorsGuide(), PCB_EDITOR_CONTROL::Group(), PCB_INSPECTION_TOOL::highlightNet(), LayerNext(), LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), EDIT_TOOL::MoveExact(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), Paste(), placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PAD_TOOL::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::RepairBoard(), PNS::TOOL_BASE::Reset(), Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), TrackDisplayMode(), ViaDisplayMode(), ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ controls()

◆ DeleteItemCursor()

int PCBNEW_CONTROL::DeleteItemCursor ( const TOOL_EVENT aEvent)

Definition at line 445 of file pcbnew_control.cpp.

446 {
448  return 0;
449 
450  std::string tool = aEvent.GetCommandStr().get();
452 
453  m_pickerItem = nullptr;
455 
456  // Deactivate other tools; particularly important if another PICKER is currently running
457  Activate();
458 
459  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
460 
461  picker->SetClickHandler(
462  [this] ( const VECTOR2D& aPosition ) -> bool
463  {
464  if( m_pickerItem )
465  {
467  {
468  STATUS_TEXT_POPUP statusPopup( m_frame );
469  statusPopup.SetText( _( "Item locked." ) );
470  statusPopup.PopupFor( 2000 );
471  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
472  return true;
473  }
474 
475  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
476  selectionTool->UnbrightenItem( m_pickerItem );
477  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
479  m_pickerItem = nullptr;
480  }
481 
482  return true;
483  } );
484 
485  picker->SetMotionHandler(
486  [this] ( const VECTOR2D& aPos )
487  {
488  BOARD* board = m_frame->GetBoard();
489  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
491  GENERAL_COLLECTOR collector;
492  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
493 
494  if( m_editModules )
495  collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
496  else
497  collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
498 
499  // Remove unselectable items
500  for( int i = collector.GetCount() - 1; i >= 0; --i )
501  {
502  if( !selectionTool->Selectable( collector[ i ] ) )
503  collector.Remove( i );
504  }
505 
506  if( collector.GetCount() > 1 )
507  selectionTool->GuessSelectionCandidates( collector, aPos );
508 
509  BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
510 
511  if( m_pickerItem != item )
512  {
513 
514  if( m_pickerItem )
515  selectionTool->UnbrightenItem( m_pickerItem );
516 
517  m_pickerItem = item;
518 
519  if( m_pickerItem )
520  selectionTool->BrightenItem( m_pickerItem );
521  }
522  } );
523 
524  picker->SetFinalizeHandler(
525  [this] ( const int& aFinalState )
526  {
527  if( m_pickerItem )
529  } );
530 
531  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
532 
533  return 0;
534 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
void GuessSelectionCandidates(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aWhere) const
Function guessSelectionCandidates() Tries to guess best selection candidates in case multiple items a...
static const KICAD_T BoardLevelItems[]
A scan list for all primary board items, omitting items which are subordinate to a MODULE,...
Definition: collectors.h:283
int m_Threshold
Definition: collector.h:67
BOARD * board() const
static TOOL_ACTION doDelete
Definition: actions.h:75
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
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.
Definition: collectors.cpp:580
SELECTION_TOOL.
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
#define HITTEST_THRESHOLD_PIXELS
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:130
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION pickerTool
Definition: actions.h:151
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
Generic tool for picking a point.
void UnbrightenItem(BOARD_ITEM *aItem)
void AddItemToSel(BOARD_ITEM *aItem, bool aQuietMode=false)
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:309
BOARD_ITEM * m_pickerItem
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
virtual bool IsLocked() const
Function IsLocked.
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
#define _(s)
Definition: 3d_actions.cpp:33
static const KICAD_T ModuleItems[]
A scan list for primary module items.
Definition: collectors.h:308
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
Function selectable() Checks conditions for an item to be selected.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
void Activate()
Function Activate() Runs the tool.
BOARD * GetBoard() const
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:390
void BrightenItem(BOARD_ITEM *aItem)
void SetCursor(const wxCursor &aCursor)
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.

References _, TOOL_INTERACTIVE::Activate(), SELECTION_TOOL::AddItemToSel(), PCB_TOOL_BASE::board(), GENERAL_COLLECTOR::BoardLevelItems, SELECTION_TOOL::BrightenItem(), GENERAL_COLLECTOR::Collect(), ACTIONS::doDelete, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCollectorsGuide(), TOOL_EVENT::GetCommandStr(), COLLECTOR::GetCount(), BOARD::GetFirstModule(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), SELECTION_TOOL::GuessSelectionCandidates(), HITTEST_THRESHOLD_PIXELS, BOARD_ITEM::IsLocked(), KiROUND(), PCB_TOOL_BASE::m_editModules, m_frame, m_pickerItem, COLLECTOR::m_Threshold, TOOL_BASE::m_toolMgr, GENERAL_COLLECTOR::ModuleItems, STATUS_POPUP::Move(), ACTIONS::pickerTool, STATUS_POPUP::PopupFor(), COLLECTOR::Remove(), TOOL_MANAGER::RunAction(), SELECTION_TOOL::Selectable(), PCB_ACTIONS::selectionClear, PCBNEW_PICKER_TOOL::SetClickHandler(), PCBNEW_PICKER_TOOL::SetCursor(), PCBNEW_PICKER_TOOL::SetFinalizeHandler(), PCBNEW_PICKER_TOOL::SetMotionHandler(), STATUS_TEXT_POPUP::SetText(), and SELECTION_TOOL::UnbrightenItem().

Referenced by setTransitions().

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

Definition at line 268 of file pcb_tool_base.cpp.

269 {
270  return frame()->GetDisplayOptions();
271 }
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
PCB_BASE_EDIT_FRAME * frame() const

References PCB_TOOL_BASE::frame(), and PCB_BASE_FRAME::GetDisplayOptions().

Referenced by PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), HighContrastMode(), HighContrastModeCycle(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PNS::TOOL_BASE::pickSingleItem(), ToggleRatsnest(), TrackDisplayMode(), ViaDisplayMode(), and ZoneDisplayMode().

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const std::string &  aTool,
INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 37 of file pcb_tool_base.cpp.

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
45  Activate();
46 
47  BOARD_COMMIT commit( frame() );
48 
50 
51  // do not capture or auto-pan until we start placing an item
52  controls()->ShowCursor( true );
53 
54  // Add a VIEW_GROUP that serves as a preview for the new item
55  PCBNEW_SELECTION preview;
56  view()->Add( &preview );
57 
58  aPlacer->m_board = board();
59  aPlacer->m_frame = frame();
60  aPlacer->m_modifiers = 0;
61 
62  auto makeNewItem = [&] ( VECTOR2I aPosition )
63  {
64  if( frame()->GetModel() )
65  newItem = aPlacer->CreateItem();
66 
67  if( newItem )
68  {
69  newItem->SetPosition( (wxPoint) aPosition );
70  preview.Add( newItem.get() );
71 
72  if( newItem->Type() == PCB_MODULE_T )
73  {
74  auto module = dyn_cast<MODULE*>( newItem.get() );
75 
76  // modules have more drawable parts
77  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
78  }
79  }
80  };
81 
82  if( aOptions & IPO_SINGLE_CLICK )
83  makeNewItem( controls()->GetCursorPosition() );
84 
85  // Main loop: keep receiving events
86  while( TOOL_EVENT* evt = Wait() )
87  {
88  if( !newItem )
89  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
90  else
91  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
92 
93  VECTOR2I cursorPos = controls()->GetCursorPosition();
94  aPlacer->m_modifiers = evt->Modifier();
95 
96  auto cleanup = [&] ()
97  {
98  newItem = nullptr;
99  preview.Clear();
100  view()->Update( &preview );
101  controls()->SetAutoPan( false );
102  controls()->CaptureCursor( false );
103  controls()->ShowCursor( true );
104  };
105 
106  if( evt->IsCancelInteractive() )
107  {
108  if( aOptions & IPO_SINGLE_CLICK )
109  {
110  cleanup();
111  frame()->PopTool( aTool );
112  break;
113  }
114  else if( newItem )
115  cleanup();
116  else
117  {
118  frame()->PopTool( aTool );
119  break;
120  }
121  }
122  else if( evt->IsActivate() )
123  {
124  if( newItem )
125  cleanup();
126 
127  if( evt->IsPointEditor() )
128  {
129  // don't exit (the point editor runs in the background)
130  }
131  else if( evt->IsMoveTool() )
132  {
133  // leave ourselves on the stack so we come back after the move
134  break;
135  }
136  else
137  {
138  frame()->PopTool( aTool );
139  break;
140  }
141  }
142  else if( evt->IsClick( BUT_LEFT ) )
143  {
144  if( !newItem )
145  {
146  // create the item if possible
147  makeNewItem( cursorPos );
148 
149  // no item created, so wait for another click
150  if( !newItem )
151  continue;
152 
153  controls()->CaptureCursor( true );
154  controls()->SetAutoPan( true );
155  }
156  else
157  {
158  auto oldFlags = newItem->GetFlags();
159  newItem->ClearFlags();
160 
161  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
162  {
163  newItem->SetFlags( oldFlags );
164  continue;
165  }
166 
167  preview.Clear();
168  newItem.release();
169  commit.Push( aCommitMessage );
170 
171  controls()->CaptureCursor( false );
172  controls()->SetAutoPan( false );
173  controls()->ShowCursor( true );
174 
175  if( !( aOptions & IPO_REPEAT ) )
176  break;
177 
178  if( aOptions & IPO_SINGLE_CLICK )
179  makeNewItem( controls()->GetCursorPosition() );
180  }
181  }
182  else if( evt->IsClick( BUT_RIGHT ) )
183  {
185  }
186  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
187  {
189  }
190  else if( newItem && evt->Category() == TC_COMMAND )
191  {
192  /*
193  * Handle any events that can affect the item as we move it around
194  */
195  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
196  {
197  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
198  newItem->Rotate( newItem->GetPosition(), rotationAngle );
199  view()->Update( &preview );
200  }
201  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
202  {
203  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
204  view()->Update( &preview );
205  }
206  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
207  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
208  {
209  // Refresh preview after event runs
211  }
212  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
213  {
214  preview.Clear();
215  newItem.release();
216 
217  makeNewItem( (wxPoint) cursorPos );
218  aPlacer->SnapItem( newItem.get() );
219  view()->Update( &preview );
220  }
221  }
222 
223  else if( newItem && evt->IsMotion() )
224  {
225  // track the cursor
226  newItem->SetPosition( (wxPoint) cursorPos );
227  aPlacer->SnapItem( newItem.get() );
228 
229  // Show a preview of the item
230  view()->Update( &preview );
231  }
232 
233  else
234  evt->SetPassEvent();
235  }
236 
237  view()->Remove( &preview );
238 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:95
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:290
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:293
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:76
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
class MODULE, a footprint
Definition: typeinfo.h:89
const PCBNEW_SELECTION & selection() const
Allow repeat placement of the item.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
PCBNEW_SETTINGS & Settings()
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:59
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:62
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:291
static TOOL_ACTION refreshPreview
Definition: actions.h:104
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and PAD_TOOL::PlacePad().

◆ DoSetGridOrigin()

void PCBNEW_CONTROL::DoSetGridOrigin ( KIGFX::VIEW aView,
PCB_BASE_FRAME aFrame,
EDA_ITEM originViewItem,
const VECTOR2D aPoint 
)
static

Definition at line 387 of file pcbnew_control.cpp.

389 {
390  aFrame->GetDesignSettings().m_GridOrigin = (wxPoint) aPoint;
391  aView->GetGAL()->SetGridOrigin( aPoint );
392  originViewItem->SetPosition( (wxPoint) aPoint );
393  aView->MarkDirty();
394  aFrame->OnModify();
395 }
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
wxPoint m_GridOrigin
origin for grid offsets
virtual void SetPosition(const wxPoint &aPos)
Definition: base_struct.h:338
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:594

References PCB_BASE_FRAME::GetDesignSettings(), KIGFX::VIEW::GetGAL(), BOARD_DESIGN_SETTINGS::m_GridOrigin, KIGFX::VIEW::MarkDirty(), PCB_BASE_FRAME::OnModify(), KIGFX::GAL::SetGridOrigin(), and EDA_ITEM::SetPosition().

Referenced by GridResetOrigin(), GridSetOrigin(), and PCB_BASE_EDIT_FRAME::PutDataInPreviousState().

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 161 of file pcb_tool_base.h.

162  {
163  return getEditFrame<PCB_BASE_EDIT_FRAME>();
164  }

Referenced by POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), ROUTER_TOOL::finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), ROUTER_TOOL::Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCBNEW_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), PCB_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getEditFrame()

template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

Returns the application window object, casted to requested user type.

Definition at line 187 of file tool_base.h.

188  {
189 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
190  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
191 #endif
192  return static_cast<T*>( getToolHolderInt() );
193  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122  {
123  return m_toolId;
124  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), TOOL_MANAGER::saveViewControls(), and TOOL_MANAGER::ShutdownTool().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

202  {
203  EDA_ITEM* m = getModelInt();
204 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
205  wxASSERT( dynamic_cast<T*>( m ) );
206 #endif
207  return static_cast<T*>( m );
208  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:54
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createZoneFromExisting(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

133  {
134  return m_toolName;
135  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:218

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

111  {
112  return m_type;
113  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:211

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::checkPart(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), GridResetOrigin(), GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43 {
44  return m_toolMgr->GetViewControls();
45 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:291

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), LIB_DRAWING_TOOLS::PlaceAnchor(), placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateItem(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 129 of file tool_interactive.h.

131 {
132  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
133 
134  goInternal( sptr, aConditions );
135 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), PCB_REANNOTATE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), LIB_PIN_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), DRC_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), LIB_CONTROL::setTransitions(), PAD_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_TOOLS::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), COMMON_TOOLS::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ GridResetOrigin()

int PCBNEW_CONTROL::GridResetOrigin ( const TOOL_EVENT aEvent)

Definition at line 434 of file pcbnew_control.cpp.

435 {
437  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
438  return 0;
439 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.

References DoSetGridOrigin(), TOOL_BASE::getView(), GRIDORIGIN, m_frame, m_gridOrigin, and PCB_BASE_FRAME::SaveCopyInUndoList().

Referenced by setTransitions().

◆ GridSetOrigin()

int PCBNEW_CONTROL::GridSetOrigin ( const TOOL_EVENT aEvent)

Definition at line 398 of file pcbnew_control.cpp.

399 {
400  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
401 
402  if( origin )
403  {
404  // We can't undo the other grid dialog settings, so no sense undoing just the origin
405  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
406  delete origin;
407  }
408  else
409  {
410  if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
411  return 0;
412 
413  std::string tool = aEvent.GetCommandStr().get();
415 
416  // Deactivate other tools; particularly important if another PICKER is currently running
417  Activate();
418 
419  picker->SetClickHandler(
420  [this] ( const VECTOR2D& pt ) -> bool
421  {
423  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
424  return false; // drill origin is a one-shot; don't continue with tool
425  } );
426 
427  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
428  }
429 
430  return 0;
431 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION pickerTool
Definition: actions.h:151
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
Generic tool for picking a point.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
void Activate()
Function Activate() Runs the tool.
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.

References TOOL_INTERACTIVE::Activate(), DoSetGridOrigin(), TOOL_EVENT::GetCommandStr(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), GRIDORIGIN, PCB_TOOL_BASE::m_editModules, m_frame, m_gridOrigin, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), ACTIONS::pickerTool, TOOL_MANAGER::RunAction(), PCB_BASE_FRAME::SaveCopyInUndoList(), and PCBNEW_PICKER_TOOL::SetClickHandler().

Referenced by setTransitions().

◆ HighContrastMode()

int PCBNEW_CONTROL::HighContrastMode ( const TOOL_EVENT aEvent)

Definition at line 211 of file pcbnew_control.cpp.

212 {
213  auto opts = displayOptions();
214 
215  opts.m_ContrastModeDisplay =
216  ( opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL ) ?
219 
220  m_frame->SetDisplayOptions( opts );
221 
222  return 0;
223 }
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Non-active layers are shown normally (no high-contrast mode)
const PCB_DISPLAY_OPTIONS & displayOptions() const

References DIMMED, PCB_TOOL_BASE::displayOptions(), m_frame, NORMAL, and PCB_BASE_FRAME::SetDisplayOptions().

Referenced by setTransitions().

◆ HighContrastModeCycle()

int PCBNEW_CONTROL::HighContrastModeCycle ( const TOOL_EVENT aEvent)

Definition at line 226 of file pcbnew_control.cpp.

227 {
228  auto opts = displayOptions();
229 
230  switch( opts.m_ContrastModeDisplay )
231  {
233  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED;
234  break;
235 
237  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN;
238  break;
239 
241  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
242  break;
243  }
244 
245  m_frame->SetDisplayOptions( opts );
246 
247  return 0;
248 }
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Non-active layers are shown normally (no high-contrast mode)
const PCB_DISPLAY_OPTIONS & displayOptions() const
Non-active layers are dimmed (old high-contrast mode)

References DIMMED, PCB_TOOL_BASE::displayOptions(), HIDDEN, m_frame, NORMAL, and PCB_BASE_FRAME::SetDisplayOptions().

Referenced by setTransitions().

◆ Init()

bool PCB_TOOL_BASE::Init ( void  )
overridevirtualinherited

Function Init() Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from TOOL_BASE.

Reimplemented in EDIT_TOOL, SELECTION_TOOL, DRAWING_TOOL, POSITION_RELATIVE_TOOL, PCB_EDITOR_CONTROL, POINT_EDITOR, FOOTPRINT_EDITOR_TOOLS, PCB_INSPECTION_TOOL, GLOBAL_EDIT_TOOL, PAD_TOOL, GROUP_TOOL, PCB_REANNOTATE_TOOL, LENGTH_TUNER_TOOL, and ROUTER_TOOL.

Definition at line 241 of file pcb_tool_base.cpp.

242 {
243  // A basic context manu. Many (but not all) tools will choose to override this.
244 
245  auto& ctxMenu = m_menu.GetMenu();
246 
247  // cancel current tool goes in main context menu at the top if present
249  ctxMenu.AddSeparator( 1 );
250 
251  // Finally, add the standard zoom/grid items
252  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
253 
254  return true;
255 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.

References CONDITIONAL_MENU::AddItem(), ACTIONS::cancelInteractive, TOOL_MENU::GetMenu(), TOOL_INTERACTIVE::m_menu, and SELECTION_CONDITIONS::ShowAlways().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by EDIT_TOOL::isRouterActive(), and ROUTER_TOOL::onViaCommand().

◆ LayerAlphaDec()

int PCBNEW_CONTROL::LayerAlphaDec ( const TOOL_EVENT aEvent)

Definition at line 360 of file pcbnew_control.cpp.

361 {
362  auto settings = m_frame->GetColorSettings();
363 
364  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
365  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
366 
367  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
368  {
369  currentColor.a -= ALPHA_STEP;
370  settings->SetColor( currentLayer, currentColor );
372 
374  view->UpdateLayerColor( currentLayer );
375 
376  wxUpdateUIEvent dummy;
377  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
378  }
379  else
380  wxBell();
381 
382  return 0;
383 }
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
#define ALPHA_MIN
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual PCB_LAYER_ID GetActiveLayer() const
double a
Alpha component.
Definition: color4d.h:369
#define ALPHA_STEP
KIGFX::PCB_VIEW * view() const
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void UpdateColors()
Updates the color settings in the painter and GAL.
int LAYER_NUM
This can be replaced with int and removed.
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:773
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
VIEW.
Definition: view.h:61
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::COLOR4D::a, ALPHA_MIN, ALPHA_STEP, dummy(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetColorSettings(), PCB_DRAW_PANEL_GAL::GetView(), m_frame, PCB_DRAW_PANEL_GAL::UpdateColors(), KIGFX::VIEW::UpdateLayerColor(), and PCB_TOOL_BASE::view().

Referenced by setTransitions().

◆ LayerAlphaInc()

int PCBNEW_CONTROL::LayerAlphaInc ( const TOOL_EVENT aEvent)

Definition at line 334 of file pcbnew_control.cpp.

335 {
336  auto settings = m_frame->GetColorSettings();
337 
338  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
339  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
340 
341  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
342  {
343  currentColor.a += ALPHA_STEP;
344  settings->SetColor( currentLayer, currentColor );
346 
348  view->UpdateLayerColor( currentLayer );
349 
350  wxUpdateUIEvent dummy;
351  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
352  }
353  else
354  wxBell();
355 
356  return 0;
357 }
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual PCB_LAYER_ID GetActiveLayer() const
double a
Alpha component.
Definition: color4d.h:369
#define ALPHA_STEP
KIGFX::PCB_VIEW * view() const
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void UpdateColors()
Updates the color settings in the painter and GAL.
int LAYER_NUM
This can be replaced with int and removed.
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:773
#define ALPHA_MAX
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
VIEW.
Definition: view.h:61
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::COLOR4D::a, ALPHA_MAX, ALPHA_STEP, dummy(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetColorSettings(), PCB_DRAW_PANEL_GAL::GetView(), m_frame, PCB_DRAW_PANEL_GAL::UpdateColors(), KIGFX::VIEW::UpdateLayerColor(), and PCB_TOOL_BASE::view().

Referenced by setTransitions().

◆ LayerNext()

int PCBNEW_CONTROL::LayerNext ( const TOOL_EVENT aEvent)

Definition at line 260 of file pcbnew_control.cpp.

261 {
262  PCB_BASE_FRAME* editFrame = m_frame;
263  BOARD* brd = board();
264  LAYER_NUM layer = editFrame->GetActiveLayer();
265  LAYER_NUM startLayer = layer;
266 
267  if( layer < F_Cu || layer > B_Cu )
268  return 0;
269 
270  while( startLayer != ++layer )
271  {
272  if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
273  break;
274 
275  if( layer >= B_Cu )
276  layer = F_Cu - 1;
277  }
278 
279  wxCHECK( IsCopperLayer( layer ), 0 );
280  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
281 
282  return 0;
283 }
BOARD * board() const
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual PCB_LAYER_ID GetActiveLayer() const
#define NULL
int LAYER_NUM
This can be replaced with int and removed.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:904
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.

References B_Cu, PCB_TOOL_BASE::board(), F_Cu, PCB_BASE_FRAME::GetActiveLayer(), IsCopperLayer(), BOARD::IsLayerVisible(), m_frame, NULL, PCB_BASE_FRAME::SwitchLayer(), and ToLAYER_ID().

Referenced by setTransitions().

◆ LayerPrev()

int PCBNEW_CONTROL::LayerPrev ( const TOOL_EVENT aEvent)

Definition at line 286 of file pcbnew_control.cpp.

287 {
288  PCB_BASE_FRAME* editFrame = m_frame;
289  BOARD* brd = board();
290  LAYER_NUM layer = editFrame->GetActiveLayer();
291  LAYER_NUM startLayer = layer;
292 
293  if( layer < F_Cu || layer > B_Cu )
294  return 0;
295 
296  while( startLayer != --layer )
297  {
298  if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
299  && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
300  break;
301 
302  if( layer <= F_Cu )
303  layer = B_Cu + 1;
304  }
305 
306 
307  wxCHECK( IsCopperLayer( layer ), 0 );
308  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
309 
310  return 0;
311 }
BOARD * board() const
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual PCB_LAYER_ID GetActiveLayer() const
#define NULL
int LAYER_NUM
This can be replaced with int and removed.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:904
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.

References B_Cu, PCB_TOOL_BASE::board(), F_Cu, PCB_BASE_FRAME::GetActiveLayer(), IsCopperLayer(), BOARD::IsLayerVisible(), m_frame, NULL, PCB_BASE_FRAME::SwitchLayer(), and ToLAYER_ID().

Referenced by setTransitions().

◆ LayerSwitch()

int PCBNEW_CONTROL::LayerSwitch ( const TOOL_EVENT aEvent)

Definition at line 252 of file pcbnew_control.cpp.

253 {
255 
256  return 0;
257 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
PCB_LAYER_ID
A quick note on layer IDs:
#define NULL
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)

References m_frame, NULL, TOOL_EVENT::Parameter(), and PCB_BASE_FRAME::SwitchLayer().

Referenced by setTransitions().

◆ LayerToggle()

int PCBNEW_CONTROL::LayerToggle ( const TOOL_EVENT aEvent)

Definition at line 314 of file pcbnew_control.cpp.

315 {
316  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
317  PCB_SCREEN* screen = m_frame->GetScreen();
318 
319  if( currentLayer == screen->m_Route_Layer_TOP )
321  else
323 
324  return 0;
325 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual PCB_LAYER_ID GetActiveLayer() const
#define NULL
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:39
int LAYER_NUM
This can be replaced with int and removed.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:38

References PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetScreen(), m_frame, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, NULL, and PCB_BASE_FRAME::SwitchLayer().

Referenced by setTransitions().

◆ module()

◆ Paste()

int PCBNEW_CONTROL::Paste ( const TOOL_EVENT aEvent)

Definition at line 613 of file pcbnew_control.cpp.

614 {
615  CLIPBOARD_IO pi;
616  BOARD_ITEM* clipItem = pi.Parse();
617 
618  if( !clipItem )
619  return 0;
620 
621  bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
622 
623  if( clipItem->Type() == PCB_T )
624  {
625  if( editModules )
626  {
627  for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
628  item->SetNet( NETINFO_LIST::OrphanedItem() );
629  }
630  else
631  static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
632  }
633 
634  // The clipboard can contain two different things, an entire kicad_pcb
635  // or a single module
636 
637  if( editModules && ( !board() || !module() ) )
638  {
639  return 0;
640  }
641 
642  switch( clipItem->Type() )
643  {
644  case PCB_T:
645  {
646  BOARD* clipBoard = static_cast<BOARD*>( clipItem );
647 
648  if( editModules )
649  {
650  MODULE* editModule = board()->GetFirstModule();
651  std::vector<BOARD_ITEM*> pastedItems;
652 
653  for( MODULE* clipModule : clipBoard->Modules() )
654  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
655 
656  for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
657  {
658  if( clipDrawItem->Type() == PCB_LINE_T )
659  {
660  DRAWSEGMENT* clipDrawSeg = static_cast<DRAWSEGMENT*>( clipDrawItem );
661 
662  // Convert to PCB_MODULE_EDGE_T
663  EDGE_MODULE* pastedDrawSeg = new EDGE_MODULE( editModule );
664  static_cast<DRAWSEGMENT*>( pastedDrawSeg )->SwapData( clipDrawSeg );
665  pastedDrawSeg->SetLocalCoord();
666 
667  // Replace parent nuked by above call to SwapData()
668  pastedDrawSeg->SetParent( editModule );
669  pastedItems.push_back( pastedDrawSeg );
670  }
671  else if( clipDrawItem->Type() == PCB_TEXT_T )
672  {
673  TEXTE_PCB* clipTextItem = static_cast<TEXTE_PCB*>( clipDrawItem );
674 
675  // Convert to PCB_MODULE_TEXT_T
676  TEXTE_MODULE* pastedTextItem = new TEXTE_MODULE( editModule );
677  static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
678  static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
679 
680  pastedTextItem->SetParent( editModule );
681  pastedItems.push_back( pastedTextItem );
682  }
683  }
684 
685  delete clipBoard;
686 
687  placeBoardItems( pastedItems, true, true );
688  }
689  else
690  {
691  placeBoardItems( clipBoard, true );
692 
694  m_frame->Compile_Ratsnest( true );
695  }
696 
697  break;
698  }
699 
700  case PCB_MODULE_T:
701  {
702  MODULE* clipModule = static_cast<MODULE*>( clipItem );
703  std::vector<BOARD_ITEM*> pastedItems;
704 
705  if( editModules )
706  {
707  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
708  delete clipModule;
709  }
710  else
711  {
712  clipModule->SetParent( board() );
713  pastedItems.push_back( clipModule );
714  }
715 
716  placeBoardItems( pastedItems, true, true );
717  break;
718  }
719 
720  default:
721  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
722  break;
723  }
724 
725  return 1;
726 }
BOARD_ITEM * Parse()
Definition: typeinfo.h:85
static NETINFO_ITEM * OrphanedItem()
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
Definition: netinfo.h:486
BOARD * board() const
void Compile_Ratsnest(bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
PCB_BASE_EDIT_FRAME * frame() const
class MODULE, a footprint
Definition: typeinfo.h:89
MODULES & Modules()
Definition: class_board.h:247
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:309
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
void SetLocalCoord()
Set relative coordinates from draw coordinates.
bool IsType(FRAME_T aType) const
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
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.
BOARD * GetBoard() const
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void pasteModuleItemsToModEdit(MODULE *aClipModule, BOARD *aBoard, std::vector< BOARD_ITEM * > &aPastedItems)
DRAWINGS & Drawings()
Definition: class_board.h:250
void DisplayToolMsg(const wxString &msg) override
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References _, PCB_TOOL_BASE::board(), BOARD::BuildConnectivity(), PCB_BASE_FRAME::Compile_Ratsnest(), EDA_DRAW_FRAME::DisplayToolMsg(), BOARD::Drawings(), PCB_TOOL_BASE::frame(), FRAME_FOOTPRINT_EDITOR, PCB_BASE_FRAME::GetBoard(), BOARD::GetFirstModule(), EDA_BASE_FRAME::IsType(), PCB_TOOL_BASE::m_editModules, m_frame, PCB_TOOL_BASE::module(), BOARD::Modules(), NETINFO_LIST::OrphanedItem(), CLIPBOARD_IO::Parse(), pasteModuleItemsToModEdit(), PCB_LINE_T, PCB_MODULE_T, PCB_T, PCB_TEXT_T, placeBoardItems(), EDGE_MODULE::SetLocalCoord(), EDA_ITEM::SetParent(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ placeBoardItems() [1/2]

int PCBNEW_CONTROL::placeBoardItems ( std::vector< BOARD_ITEM * > &  aItems,
bool  aIsNew,
bool  aAnchorAtOrigin 
)
private

Add and select or just select for move/place command a list of board items.

Parameters
aItemsis the list of items
aIsNew= true to add items to the current board, false to just select if items are already managed by the current board
aAnchorAtOrigin= true if the items are translated so that the anchor is {0, 0} (if false, the top-left item's origin will be used)

Definition at line 832 of file pcbnew_control.cpp.

834 {
836 
837  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
838  EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
839 
840  PCBNEW_SELECTION& selection = selectionTool->GetSelection();
841 
842  for( BOARD_ITEM* item : aItems )
843  {
844  if( aIsNew )
845  {
846  const_cast<KIID&>( item->m_Uuid ) = KIID();
847 
848  if( item->Type() == PCB_MODULE_T )
849  {
850  static_cast<MODULE*>( item )->SetPath( KIID_PATH() );
851  }
852 
853  if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
854  {
855  selectionTool->GetEnteredGroup()->AddItem( item );
856  }
857  }
858 
859  // Add or just select items for the move/place command
860  if( aIsNew )
861  editTool->GetCurrentCommit()->Add( item );
862  else
863  editTool->GetCurrentCommit()->Added( item );
864 
865  // Matching the logic of SELECTION_TOOL::select for PCB_GROUP_T, there
866  // is a distinction between which items are SetSelected and which are in
867  // the selection object. Top-level groups or items not in groups are
868  // added to the selection object (via selection.Add(), below), but all
869  // items have SetSelected called. This is because much of the selection
870  // management logic (e.g. move) recursively acts on groups in the
871  // selection, so descendents of groups should not be in the selection
872  // object.
873  item->SetSelected();
874 
875  if( !item->GetParentGroup() || !item->GetParentGroup()->IsSelected() )
876  selection.Add( item );
877  }
878 
879  if( selection.Size() > 0 )
880  {
881  if( aAnchorAtOrigin )
882  {
884  }
885  else
886  {
887  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
889  }
890 
891  getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
892 
895  }
896 
897  return 0;
898 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
PCB_GROUP * GetParentGroup() const
bool AddItem(BOARD_ITEM *aItem)
Adds item to group.
static const TOOL_EVENT SelectedEvent
Definition: actions.h:206
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:95
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
Definition: common.h:68
class MODULE, a footprint
Definition: typeinfo.h:89
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
const PCBNEW_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
EDIT_TOOL.
Definition: edit_tool.h:74
PCB_GROUP * GetEnteredGroup()
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42

References SELECTION::Add(), PCB_GROUP::AddItem(), SELECTION_TOOL::GetEnteredGroup(), BOARD_ITEM::GetParentGroup(), EDA_ITEM::GetPosition(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), PCBNEW_SELECTION::GetTopLeftItem(), TOOL_BASE::getViewControls(), TOOL_BASE::m_toolMgr, PCB_ACTIONS::move, PCB_MODULE_T, TOOL_MANAGER::ProcessEvent(), TOOL_MANAGER::RunAction(), EVENTS::SelectedEvent, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetCursorPosition(), SELECTION::SetReferencePoint(), and SELECTION::Size().

Referenced by AppendBoard(), Paste(), and placeBoardItems().

◆ placeBoardItems() [2/2]

int PCBNEW_CONTROL::placeBoardItems ( BOARD aBoard,
bool  aAnchorAtOrigin 
)
private

Definition at line 810 of file pcbnew_control.cpp.

811 {
812  // items are new if the current board is not the board source
813  bool isNew = board() != aBoard;
814  std::vector<BOARD_ITEM*> items;
815 
816  moveUnflaggedItems( aBoard->Tracks(), items, isNew );
817  moveUnflaggedItems( aBoard->Modules(), items, isNew );
818  moveUnflaggedItems( aBoard->Drawings(), items, isNew );
819  moveUnflaggedItems( aBoard->Zones(), items, isNew );
820 
821  // Subtlety: When selecting a group via the mouse,
822  // SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
823  // descendants. In PCBNEW_CONTROL::placeBoardItems, below, we skip that and
824  // mark items non-recursively. That works because the saving of the
825  // selection created aBoard that has the group and all descendents in it.
826  moveUnflaggedItems( aBoard->Groups(), items, isNew );
827 
828  return placeBoardItems( items, isNew, aAnchorAtOrigin );
829 }
BOARD * board() const
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: class_board.h:266
static void moveUnflaggedItems(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
MODULES & Modules()
Definition: class_board.h:247
ZONE_CONTAINERS & Zones()
Definition: class_board.h:253
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.
DRAWINGS & Drawings()
Definition: class_board.h:250
TRACKS & Tracks()
Definition: class_board.h:244

References PCB_TOOL_BASE::board(), BOARD::Drawings(), BOARD::Groups(), BOARD::Modules(), moveUnflaggedItems(), placeBoardItems(), BOARD::Tracks(), and BOARD::Zones().

◆ Print()

int PCBNEW_CONTROL::Print ( const TOOL_EVENT aEvent)

Definition at line 443 of file dialog_print_pcbnew.cpp.

444 {
445  // Selection affects the origin item visibility
447 
449  DIALOG_PRINT_PCBNEW dlg( (PCB_BASE_EDIT_FRAME*) m_frame, &settings );
450 
451  if( m_editModules )
452  dlg.ForcePrintBorder( false );
453 
454  dlg.ShowModal();
455 
456  return 0;
457 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Common, abstract interface for edit frames.
const PAGE_INFO & GetPageSettings() const override

References PCB_BASE_FRAME::GetPageSettings(), PCB_TOOL_BASE::m_editModules, m_frame, TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), and PCB_ACTIONS::selectionClear.

Referenced by setTransitions().

◆ Quit()

int PCBNEW_CONTROL::Quit ( const TOOL_EVENT aEvent)

Definition at line 104 of file pcbnew_control.cpp.

105 {
106  m_frame->Close( false );
107  return 0;
108 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.

References m_frame.

Referenced by setTransitions().

◆ Redo()

int PCBNEW_CONTROL::Redo ( const TOOL_EVENT aEvent)

Definition at line 1003 of file pcbnew_control.cpp.

1004 {
1005  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1006  wxCommandEvent dummy;
1007 
1008  if( editFrame )
1009  editFrame->RestoreCopyFromRedoList( dummy );
1010 
1011  return 0;
1012 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Common, abstract interface for edit frames.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Function RestoreCopyFromRedoList Redo the last edit:
Definition: undo_redo.cpp:364

References dummy(), m_frame, and PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList().

Referenced by setTransitions().

◆ Reset()

void PCBNEW_CONTROL::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL_BASE.

Definition at line 76 of file pcbnew_control.cpp.

77 {
78  m_frame = getEditFrame<PCB_BASE_FRAME>();
79 
80  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
81  {
82  m_gridOrigin->SetPosition( board()->GetDesignSettings().m_GridOrigin );
83  m_gridOrigin->SetColor( m_frame->GetGridColor() );
84  getView()->Remove( m_gridOrigin.get() );
85  getView()->Add( m_gridOrigin.get() );
86  }
87 }
BOARD * board() const
Model changes (required full reload)
Definition: tool_base.h:82
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:375
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual COLOR4D GetGridColor()
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:345
Rendering engine changes.
Definition: tool_base.h:83

References KIGFX::VIEW::Add(), PCB_TOOL_BASE::board(), TOOL_BASE::GAL_SWITCH, EDA_DRAW_FRAME::GetGridColor(), TOOL_BASE::getView(), m_frame, m_gridOrigin, TOOL_BASE::MODEL_RELOAD, and KIGFX::VIEW::Remove().

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ selection() [1/2]

const PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 279 of file pcb_tool_base.cpp.

280 {
281  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
282  const auto& selection = selTool->GetSelection();
283  return selection;
284 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

References TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), PCB_EDITOR_CONTROL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), PCB_EDITOR_CONTROL::Group(), PCB_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), PCB_EDITOR_CONTROL::RemoveFromGroup(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCB_EDITOR_CONTROL::Ungroup(), UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 287 of file pcb_tool_base.cpp.

288 {
289  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
290  auto& selection = selTool->GetSelection();
291  return selection;
292 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

References TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL_BASE::selection().

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

Assigns a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 76 of file tool_interactive.cpp.

77 {
78  if( aMenu )
79  aMenu->SetTool( this );
80  else
81  aTrigger = CMENU_OFF;
82 
83  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SetTool(TOOL_INTERACTIVE *aTool)
Sets a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

Toggles edit module mode. When enabled, one may select parts of modules individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 101 of file pcb_tool_base.h.

102  {
103  m_editModules = aEnabled;
104  }

References PCB_TOOL_BASE::m_editModules.

◆ setTransitions()

void PCBNEW_CONTROL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1081 of file pcbnew_control.cpp.

1082 {
1085  Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
1086  Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1087 
1088  // Display modes
1099 
1100  // Layer control
1138 
1139  // Grid control
1142 
1143  Go( &PCBNEW_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1144  Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1145 
1146  // Miscellaneous
1148 
1149  // Append control
1151 
1152  Go( &PCBNEW_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1153 
1158 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:276
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:271
static const TOOL_EVENT SelectedEvent
Definition: actions.h:206
static TOOL_ACTION layerNext
Definition: pcb_actions.h:277
int ToggleRatsnest(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:247
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:250
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:251
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:252
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:253
int AddLibrary(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:266
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:233
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:280
static TOOL_ACTION gridResetOrigin
Definition: actions.h:136
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:239
int HighContrastModeCycle(const TOOL_EVENT &aEvent)
int Quit(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:279
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:238
int HighContrastMode(const TOOL_EVENT &aEvent)
int LayerPrev(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int GridSetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION print
Definition: actions.h:60
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:248
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:269
int LayerNext(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:256
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:211
static TOOL_ACTION layerTop
Definition: pcb_actions.h:245
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:268
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:425
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:240
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:258
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:278
int GridResetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:270
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:263
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:275
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:274
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:232
int LayerToggle(const TOOL_EVENT &aEvent)
static TOOL_ACTION addLibrary
Definition: actions.h:52
static TOOL_ACTION quit
Definition: actions.h:62
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:255
static const TOOL_EVENT ClearedEvent
Definition: actions.h:208
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:260
static TOOL_ACTION newLibrary
Definition: actions.h:51
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:273
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:272
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:262
int Redo(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:265
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:236
static TOOL_ACTION redo
Definition: actions.h:68
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:267
int LayerAlphaDec(const TOOL_EVENT &aEvent)
int ViaDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:259
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:254
int TrackDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:261
static TOOL_ACTION deleteTool
Definition: actions.h:76
int DeleteItemCursor(const TOOL_EVENT &aEvent)
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:102
int Undo(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:249
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION gridSetOrigin
Definition: actions.h:135
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:264
int LayerSwitch(const TOOL_EVENT &aEvent)
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:246
static TOOL_ACTION highContrastMode
Definition: actions.h:101
static TOOL_ACTION paste
Definition: actions.h:71
int Print(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:234
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:257
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:281
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:237

References ACTIONS::addLibrary, AddLibrary(), PCB_ACTIONS::appendBoard, AppendBoardFromFile(), EVENTS::ClearedEvent, DeleteItemCursor(), ACTIONS::deleteTool, TOOL_INTERACTIVE::Go(), GridResetOrigin(), ACTIONS::gridResetOrigin, GridSetOrigin(), ACTIONS::gridSetOrigin, HighContrastMode(), ACTIONS::highContrastMode, HighContrastModeCycle(), ACTIONS::highContrastModeCycle, LayerAlphaDec(), PCB_ACTIONS::layerAlphaDec, LayerAlphaInc(), PCB_ACTIONS::layerAlphaInc, PCB_ACTIONS::layerBottom, PCB_ACTIONS::layerInner1, PCB_ACTIONS::layerInner10, PCB_ACTIONS::layerInner11, PCB_ACTIONS::layerInner12, PCB_ACTIONS::layerInner13, PCB_ACTIONS::layerInner14, PCB_ACTIONS::layerInner15, PCB_ACTIONS::layerInner16, PCB_ACTIONS::layerInner17, PCB_ACTIONS::layerInner18, PCB_ACTIONS::layerInner19, PCB_ACTIONS::layerInner2, PCB_ACTIONS::layerInner20, PCB_ACTIONS::layerInner21, PCB_ACTIONS::layerInner22, PCB_ACTIONS::layerInner23, PCB_ACTIONS::layerInner24, PCB_ACTIONS::layerInner25, PCB_ACTIONS::layerInner26, PCB_ACTIONS::layerInner27, PCB_ACTIONS::layerInner28, PCB_ACTIONS::layerInner29, PCB_ACTIONS::layerInner3, PCB_ACTIONS::layerInner30, PCB_ACTIONS::layerInner4, PCB_ACTIONS::layerInner5, PCB_ACTIONS::layerInner6, PCB_ACTIONS::layerInner7, PCB_ACTIONS::layerInner8, PCB_ACTIONS::layerInner9, LayerNext(), PCB_ACTIONS::layerNext, LayerPrev(), PCB_ACTIONS::layerPrev, LayerSwitch(), LayerToggle(), PCB_ACTIONS::layerToggle, PCB_ACTIONS::layerTop, ACTIONS::newLibrary, ACTIONS::paste, Paste(), Print(), ACTIONS::print, Quit(), ACTIONS::quit, PCB_ACTIONS::ratsnestLineMode, ACTIONS::redo, Redo(), EVENTS::SelectedEvent, EVENTS::SelectedItemsModified, PCB_ACTIONS::showRatsnest, ToggleRatsnest(), TrackDisplayMode(), PCB_ACTIONS::trackDisplayMode, ACTIONS::undo, Undo(), EVENTS::UnselectedEvent, UpdateMessagePanel(), ViaDisplayMode(), PCB_ACTIONS::viaDisplayMode, PCB_ACTIONS::zoneDisplayDisable, PCB_ACTIONS::zoneDisplayEnable, ZoneDisplayMode(), PCB_ACTIONS::zoneDisplayOutlines, and PCB_ACTIONS::zoneDisplayToggle.

◆ ToggleRatsnest()

int PCBNEW_CONTROL::ToggleRatsnest ( const TOOL_EVENT aEvent)

Definition at line 136 of file pcbnew_control.cpp.

137 {
138  auto opts = displayOptions();
139 
140  if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
141  {
142  // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
143  Flip( opts.m_ShowGlobalRatsnest );
144  m_frame->SetDisplayOptions( opts );
145  getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
146  opts.m_ShowGlobalRatsnest );
147 
148  }
149  else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
150  {
151  Flip( opts.m_DisplayRatsnestLinesCurved );
152  m_frame->SetDisplayOptions( opts );
153  }
154 
155  canvas()->RedrawRatsnest();
156  canvas()->Refresh();
157 
158  return 0;
159 }
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:233
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
void RedrawRatsnest()
Forces refresh of the ratsnest visual representation
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:232
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...
const PCB_DISPLAY_OPTIONS & displayOptions() const
PCB_DRAW_PANEL_GAL * canvas() const
void Flip(T &aValue)

References PCB_TOOL_BASE::canvas(), PCB_TOOL_BASE::displayOptions(), Flip(), TOOL_EVENT::IsAction(), LAYER_RATSNEST, m_frame, PCB_ACTIONS::ratsnestLineMode, PCB_DRAW_PANEL_GAL::RedrawRatsnest(), EDA_DRAW_PANEL_GAL::Refresh(), PCB_BASE_FRAME::SetDisplayOptions(), and PCB_ACTIONS::showRatsnest.

Referenced by setTransitions().

◆ TrackDisplayMode()

int PCBNEW_CONTROL::TrackDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 117 of file pcbnew_control.cpp.

118 {
119  auto opts = displayOptions();
120 
121  Flip( opts.m_DisplayPcbTrackFill );
122  m_frame->SetDisplayOptions( opts );
123 
124  for( auto track : board()->Tracks() )
125  {
126  if( track->Type() == PCB_TRACE_T )
127  view()->Update( track, KIGFX::GEOMETRY );
128  }
129 
130  canvas()->Refresh();
131 
132  return 0;
133 }
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
KIGFX::PCB_VIEW * view() const
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...
const PCB_DISPLAY_OPTIONS & displayOptions() const
PCB_DRAW_PANEL_GAL * canvas() const
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:59

References PCB_TOOL_BASE::board(), PCB_TOOL_BASE::canvas(), PCB_TOOL_BASE::displayOptions(), Flip(), KIGFX::GEOMETRY, m_frame, PCB_TRACE_T, EDA_DRAW_PANEL_GAL::Refresh(), PCB_BASE_FRAME::SetDisplayOptions(), KIGFX::PCB_VIEW::Update(), and PCB_TOOL_BASE::view().

Referenced by setTransitions().

◆ Undo()

int PCBNEW_CONTROL::Undo ( const TOOL_EVENT aEvent)

Definition at line 991 of file pcbnew_control.cpp.

992 {
993  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
994  wxCommandEvent dummy;
995 
996  if( editFrame )
997  editFrame->RestoreCopyFromUndoList( dummy );
998 
999  return 0;
1000 }
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Function RestoreCopyFromUndoList Undo the last edit:
Definition: undo_redo.cpp:335
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Common, abstract interface for edit frames.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.

References dummy(), m_frame, and PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList().

Referenced by setTransitions().

◆ UpdateMessagePanel()

int PCBNEW_CONTROL::UpdateMessagePanel ( const TOOL_EVENT aEvent)

Definition at line 1015 of file pcbnew_control.cpp.

1016 {
1018  PCBNEW_SELECTION& selection = selTool->GetSelection();
1019 
1020  if( selection.GetSize() == 1 )
1021  {
1022  EDA_ITEM* item = selection.Front();
1023  MSG_PANEL_ITEMS msgItems;
1024 
1025  item->GetMsgPanelInfo( m_frame, msgItems );
1026  m_frame->SetMsgPanel( msgItems );
1027  }
1028  else if( selection.GetSize() > 1 )
1029  {
1030  MSG_PANEL_ITEMS msgItems;
1031  wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
1032 
1033  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
1034  m_frame->SetMsgPanel( msgItems );
1035  }
1036  else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
1037  {
1038  MODULE* footprint = static_cast<MODULE*>( editFrame->GetModel() );
1039 
1040  if( !footprint )
1041  return 0;
1042 
1043  MSG_PANEL_ITEMS msgItems;
1044  wxString msg;
1045 
1046  msg = footprint->GetFPID().GetLibNickname().wx_str();
1047  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
1048 
1049  msg = footprint->GetFPID().GetLibItemName().wx_str();
1050  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
1051 
1052  wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
1053 
1054  if( footprint->GetLastEditTime() && date.IsValid() )
1055  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
1056  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
1057  else
1058  msg = _( "Unknown" );
1059 
1060  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
1061 
1062  msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
1063  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
1064 
1065  wxString doc, keyword;
1066  doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
1067  keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
1068  msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
1069 
1070  m_frame->SetMsgPanel( msgItems );
1071  }
1072  else
1073  {
1075  }
1076 
1077  return 0;
1078 }
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
GetPadCount returns the number of pads.
timestamp_t GetLastEditTime() const
Definition: class_module.h:359
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
Definition: color4d.h:61
const LIB_ID & GetFPID() const
Definition: class_module.h:228
Definition: color4d.h:44
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
const PCBNEW_SELECTION & selection() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: base_struct.h:295
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
const wxString & GetKeywords() const
Definition: class_module.h:234
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
const wxString & GetDescription() const
Definition: class_module.h:231
Definition: color4d.h:56
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
#define _(s)
Definition: 3d_actions.cpp:33
wxString wx_str() const
Definition: utf8.cpp:51
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
BOARD * GetBoard() const
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
EDA_ITEM * Front() const
Definition: selection.h:184

References _, BLACK, BLUE, BROWN, DARKCYAN, DO_NOT_INCLUDE_NPTH, Format(), SELECTION::Front(), PCB_BASE_FRAME::GetBoard(), MODULE::GetDescription(), MODULE::GetFPID(), MODULE::GetKeywords(), MODULE::GetLastEditTime(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), EDA_ITEM::GetMsgPanelInfo(), MODULE::GetPadCount(), SELECTION_TOOL::GetSelection(), SELECTION::GetSize(), TOOL_MANAGER::GetTool(), m_frame, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::selection(), EDA_DRAW_FRAME::SetMsgPanel(), and UTF8::wx_str().

Referenced by setTransitions().

◆ ViaDisplayMode()

int PCBNEW_CONTROL::ViaDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 162 of file pcbnew_control.cpp.

163 {
164  auto opts = displayOptions();
165 
166  Flip( opts.m_DisplayViaFill );
167  m_frame->SetDisplayOptions( opts );
168 
169  for( auto track : board()->Tracks() )
170  {
171  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
172  view()->Update( track, KIGFX::GEOMETRY );
173  }
174 
175  canvas()->Refresh();
176 
177  return 0;
178 }
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
KIGFX::PCB_VIEW * view() const
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...
const PCB_DISPLAY_OPTIONS & displayOptions() const
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
PCB_DRAW_PANEL_GAL * canvas() const
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:59

References PCB_TOOL_BASE::board(), PCB_TOOL_BASE::canvas(), PCB_TOOL_BASE::displayOptions(), Flip(), KIGFX::GEOMETRY, m_frame, PCB_TRACE_T, PCB_VIA_T, EDA_DRAW_PANEL_GAL::Refresh(), PCB_BASE_FRAME::SetDisplayOptions(), KIGFX::PCB_VIEW::Update(), and PCB_TOOL_BASE::view().

Referenced by setTransitions().

◆ view()

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ ZoneDisplayMode()

int PCBNEW_CONTROL::ZoneDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 181 of file pcbnew_control.cpp.

182 {
183  auto opts = displayOptions();
184 
185  // Apply new display options to the GAL canvas
187  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
188  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
189  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::HIDE_FILLED;
190  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
191  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_OUTLINED;
192  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
193  {
194  int nextMode = ( static_cast<int>( opts.m_ZoneDisplayMode ) + 1 ) % 3;
195  opts.m_ZoneDisplayMode = static_cast<ZONE_DISPLAY_MODE>( nextMode );
196  }
197  else
198  wxFAIL;
199 
200  m_frame->SetDisplayOptions( opts );
201 
202  for( ZONE_CONTAINER* zone : board()->Zones() )
203  view()->Update( zone, KIGFX::GEOMETRY );
204 
205  canvas()->Refresh();
206 
207  return 0;
208 }
Filled polygons are shown.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:239
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:238
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
Only the zone outline is shown.
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:240
KIGFX::PCB_VIEW * view() const
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...
const PCB_DISPLAY_OPTIONS & displayOptions() const
PCB_DRAW_PANEL_GAL * canvas() const
Outlines of filled polygons are shown.
Color has changed.
Definition: view_item.h:59
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:237

References PCB_TOOL_BASE::board(), PCB_TOOL_BASE::canvas(), PCB_TOOL_BASE::displayOptions(), KIGFX::GEOMETRY, HIDE_FILLED, TOOL_EVENT::IsAction(), m_frame, EDA_DRAW_PANEL_GAL::Refresh(), PCB_BASE_FRAME::SetDisplayOptions(), SHOW_FILLED, SHOW_OUTLINED, KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), PCB_ACTIONS::zoneDisplayDisable, PCB_ACTIONS::zoneDisplayEnable, PCB_ACTIONS::zoneDisplayOutlines, and PCB_ACTIONS::zoneDisplayToggle.

Referenced by setTransitions().

Member Data Documentation

◆ m_editModules

◆ m_frame

◆ m_gridOrigin

std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> PCBNEW_CONTROL::m_gridOrigin
private

Grid origin marker.

Definition at line 115 of file pcbnew_control.h.

Referenced by GridResetOrigin(), GridSetOrigin(), PCBNEW_CONTROL(), and Reset().

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), ROUTER_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), PICKER_TOOL::Init(), PL_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), LIB_CONTROL::Init(), LIB_DRAWING_TOOLS::Init(), FOOTPRINT_EDITOR_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), EDA_3D_CONTROLLER::Init(), GERBVIEW_SELECTION_TOOL::Init(), PL_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_pickerItem

BOARD_ITEM* PCBNEW_CONTROL::m_pickerItem
private

Definition at line 117 of file pcbnew_control.h.

Referenced by DeleteItemCursor().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and TOOL_BASE::IsToolActive().

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), LIB_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), PCB_EDITOR_CONTROL::EnterGroup(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), GridSetOrigin(), PCB_EDITOR_CONTROL::Group(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), CONVERT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), LIB_CONTROL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_INSPECTION_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), PCB_EDITOR_CONTROL::LeaveGroup(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), LIB_EDIT_TOOL::PinTable(), placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), SCH_EDIT_TOOL::RefreshSymbolFromLibrary(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PCB_EDITOR_CONTROL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), PCB_EDITOR_CONTROL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

Referenced by TOOL_BASE::GetType(), and BOARD_COMMIT::Push().


The documentation for this class was generated from the following files: