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 ApplyLayerPreset (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, BOARD_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(), 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::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 872 of file pcbnew_control.cpp.

873 {
874  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
875 
876  if( !editFrame )
877  return 1;
878 
879  BOARD* brd = board();
880 
881  if( !brd )
882  return 1;
883 
884  // Mark existing items, in order to know what are the new items so we can select only
885  // the new items after loading
886  for( auto track : brd->Tracks() )
887  track->SetFlags( SKIP_STRUCT );
888 
889  for( auto module : brd->Modules() )
891 
892  for( auto drawing : brd->Drawings() )
893  drawing->SetFlags( SKIP_STRUCT );
894 
895  for( auto zone : brd->Zones() )
896  zone->SetFlags( SKIP_STRUCT );
897 
898  // Keep also the count of copper layers, to adjust if necessary
899  int initialCopperLayerCount = brd->GetCopperLayerCount();
900  LSET initialEnabledLayers = brd->GetEnabledLayers();
901 
902  // Load the data
903  try
904  {
905  PROPERTIES props;
906  char xbuf[30];
907  char ybuf[30];
908 
909  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
910  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
911  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
912 
913  props["page_width"] = xbuf;
914  props["page_height"] = ybuf;
915 
916  editFrame->GetDesignSettings().GetNetClasses().Clear();
917  pi.Load( fileName, brd, &props );
918  }
919  catch( const IO_ERROR& ioe )
920  {
921  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
922  DisplayError( editFrame, msg );
923 
924  return 0;
925  }
926 
927  // rebuild nets and ratsnest before any use of nets
928  brd->BuildListOfNets();
930  brd->BuildConnectivity();
931 
932  // Synchronize layers
933  // we should not ask PLUGINs to do these items:
934  int copperLayerCount = brd->GetCopperLayerCount();
935 
936  if( copperLayerCount > initialCopperLayerCount )
937  brd->SetCopperLayerCount( copperLayerCount );
938 
939  // Enable all used layers, and make them visible:
940  LSET enabledLayers = brd->GetEnabledLayers();
941  enabledLayers |= initialEnabledLayers;
942  brd->SetEnabledLayers( enabledLayers );
943  brd->SetVisibleLayers( enabledLayers );
944 
945  return placeBoardItems( brd, false );
946 }
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:718
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
BOARD * board() const
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
void SetCopperLayerCount(int aCount)
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
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.
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
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:33
MODULES & Modules()
Definition: class_board.h:266
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
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:280
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.
Definition: netclass.h:236
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:205
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
int GetCopperLayerCount() const
Function GetCopperLayerCount.
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:275
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
TRACKS & Tracks()
Definition: class_board.h:257
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(), PLUGIN::Load(), m_frame, PCB_TOOL_BASE::module(), BOARD::Modules(), placeBoardItems(), BOARD::SetCopperLayerCount(), BOARD::SetEnabledLayers(), EDA_ITEM::SetFlags(), 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 732 of file pcbnew_control.cpp.

733 {
734  int open_ctl;
735  wxString fileName;
736 
737  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
738 
739  if( !editFrame )
740  return 1;
741 
742  // Pick a file to append
743  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
744  return 1;
745 
746  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
747  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
748 
749  return AppendBoard( *pi, fileName );
750 }
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:579
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:61
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().

◆ ApplyLayerPreset()

int PCBNEW_CONTROL::ApplyLayerPreset ( const TOOL_EVENT aEvent)

◆ 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(), DRAWING_TOOL::constrainDimension(), 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::filterSelection(), SELECTION_TOOL::getCollectorsGuide(), 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(), PNS::TOOL_BASE::Reset(), Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), TrackDisplayMode(), POINT_EDITOR::updateItem(), 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 450 of file pcbnew_control.cpp.

451 {
453  return 0;
454 
455  std::string tool = aEvent.GetCommandStr().get();
457 
458  m_pickerItem = nullptr;
460 
461  // Deactivate other tools; particularly important if another PICKER is currently running
462  Activate();
463 
464  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
465 
466  picker->SetClickHandler(
467  [this] ( const VECTOR2D& aPosition ) -> bool
468  {
469  if( m_pickerItem )
470  {
472  {
473  STATUS_TEXT_POPUP statusPopup( m_frame );
474  statusPopup.SetText( _( "Item locked." ) );
475  statusPopup.PopupFor( 2000 );
476  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
477  return true;
478  }
479 
480  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
481  selectionTool->UnbrightenItem( m_pickerItem );
482  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
484  m_pickerItem = nullptr;
485  }
486 
487  return true;
488  } );
489 
490  picker->SetMotionHandler(
491  [this] ( const VECTOR2D& aPos )
492  {
493  BOARD* board = m_frame->GetBoard();
494  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
496  GENERAL_COLLECTOR collector;
497  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
498 
499  if( m_editModules )
500  collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
501  else
502  collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
503 
504  // Remove unselectable items
505  for( int i = collector.GetCount() - 1; i >= 0; --i )
506  {
507  if( !selectionTool->Selectable( collector[ i ] ) )
508  collector.Remove( i );
509  }
510 
511  if( collector.GetCount() > 1 )
512  selectionTool->GuessSelectionCandidates( collector, aPos );
513 
514  BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
515 
516  if( m_pickerItem != item )
517  {
518 
519  if( m_pickerItem )
520  selectionTool->UnbrightenItem( m_pickerItem );
521 
522  m_pickerItem = item;
523 
524  if( m_pickerItem )
525  selectionTool->BrightenItem( m_pickerItem );
526  }
527  } );
528 
529  picker->SetFinalizeHandler(
530  [this] ( const int& aFinalState )
531  {
532  if( m_pickerItem )
534  } );
535 
536  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
537 
538  return 0;
539 }
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:74
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:539
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:149
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:330
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.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
#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:385
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 264 of file pcb_tool_base.cpp.

265 {
266  return frame()->GetDisplayOptions();
267 }
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  controls()->SetSnapping( true );
54 
55  // Add a VIEW_GROUP that serves as a preview for the new item
56  PCBNEW_SELECTION preview;
57  view()->Add( &preview );
58 
59  aPlacer->m_board = board();
60  aPlacer->m_frame = frame();
61  aPlacer->m_modifiers = 0;
62 
63  auto makeNewItem = [&] ( VECTOR2I aPosition )
64  {
65  if( frame()->GetModel() )
66  newItem = aPlacer->CreateItem();
67 
68  if( newItem )
69  {
70  newItem->SetPosition( (wxPoint) aPosition );
71  preview.Add( newItem.get() );
72 
73  if( newItem->Type() == PCB_MODULE_T )
74  {
75  auto module = dyn_cast<MODULE*>( newItem.get() );
76 
77  // modules have more drawable parts
78  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
79  }
80  }
81  };
82 
83  if( aOptions & IPO_SINGLE_CLICK )
84  makeNewItem( controls()->GetCursorPosition() );
85 
86  // Main loop: keep receiving events
87  while( TOOL_EVENT* evt = Wait() )
88  {
89  if( !newItem )
90  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
91  else
92  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
93 
94  VECTOR2I cursorPos = controls()->GetCursorPosition();
95  aPlacer->m_modifiers = evt->Modifier();
96 
97  auto cleanup = [&] ()
98  {
99  newItem = nullptr;
100  preview.Clear();
101  view()->Update( &preview );
102  controls()->SetAutoPan( false );
103  controls()->CaptureCursor( false );
104  controls()->ShowCursor( true );
105  };
106 
107  if( evt->IsCancelInteractive() )
108  {
109  if( aOptions & IPO_SINGLE_CLICK )
110  {
111  cleanup();
112  frame()->PopTool( aTool );
113  break;
114  }
115  else if( newItem )
116  cleanup();
117  else
118  {
119  frame()->PopTool( aTool );
120  break;
121  }
122  }
123  else if( evt->IsActivate() )
124  {
125  if( newItem )
126  cleanup();
127 
128  if( evt->IsPointEditor() )
129  {
130  // don't exit (the point editor runs in the background)
131  }
132  else if( evt->IsMoveTool() )
133  {
134  // leave ourselves on the stack so we come back after the move
135  break;
136  }
137  else
138  {
139  frame()->PopTool( aTool );
140  break;
141  }
142  }
143  else if( evt->IsClick( BUT_LEFT ) )
144  {
145  if( !newItem )
146  {
147  // create the item if possible
148  makeNewItem( cursorPos );
149 
150  // no item created, so wait for another click
151  if( !newItem )
152  continue;
153 
154  controls()->CaptureCursor( true );
155  controls()->SetAutoPan( true );
156  }
157  else
158  {
159  auto oldFlags = newItem->GetFlags();
160  newItem->ClearFlags();
161 
162  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
163  {
164  newItem->SetFlags( oldFlags );
165  continue;
166  }
167 
168  preview.Clear();
169  newItem.release();
170  commit.Push( aCommitMessage );
171 
172  controls()->CaptureCursor( false );
173  controls()->SetAutoPan( false );
174  controls()->ShowCursor( true );
175 
176  if( !( aOptions & IPO_REPEAT ) )
177  break;
178 
179  if( aOptions & IPO_SINGLE_CLICK )
180  makeNewItem( controls()->GetCursorPosition() );
181  }
182  }
183  else if( evt->IsClick( BUT_RIGHT ) )
184  {
186  }
187  else if( newItem && evt->Category() == TC_COMMAND )
188  {
189  /*
190  * Handle any events that can affect the item as we move it around
191  */
192  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
193  {
194  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
195  newItem->Rotate( newItem->GetPosition(), rotationAngle );
196  view()->Update( &preview );
197  }
198  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
199  {
200  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
201  view()->Update( &preview );
202  }
203  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
204  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
205  {
206  // Refresh preview after event runs
208  }
209  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
210  {
211  preview.Clear();
212  newItem.release();
213 
214  makeNewItem( controls()->GetCursorPosition() );
215  view()->Update( &preview );
216  }
217  }
218 
219  else if( newItem && evt->IsMotion() )
220  {
221  // track the cursor
222  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
223  aPlacer->SnapItem( newItem.get() );
224 
225  // Show a preview of the item
226  view()->Update( &preview );
227  }
228 
229  else
230  evt->SetPassEvent();
231  }
232 
233  view()->Remove( &preview );
234 }
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:91
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:282
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.
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
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:74
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:103
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:58
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:283
static TOOL_ACTION refreshPreview
Definition: actions.h:102
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(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ DoSetGridOrigin()

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

Definition at line 392 of file pcbnew_control.cpp.

394 {
395  aFrame->GetDesignSettings().m_GridOrigin = (wxPoint) aPoint;
396  aView->GetGAL()->SetGridOrigin( aPoint );
397  originViewItem->SetPosition( (wxPoint) aPoint );
398  aView->MarkDirty();
399  aFrame->OnModify();
400 }
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)=0
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:610

References PCB_BASE_FRAME::GetDesignSettings(), KIGFX::VIEW::GetGAL(), BOARD_DESIGN_SETTINGS::m_GridOrigin, KIGFX::VIEW::MarkDirty(), PCB_BASE_FRAME::OnModify(), KIGFX::GAL::SetGridOrigin(), and BOARD_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(), EDIT_TOOL::doMoveSelection(), 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(), 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(), EDIT_TOOL::pickReferencePoint(), 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(), POINT_EDITOR::updateItem(), 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::createNewZone(), 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:284
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::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(), 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(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), 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(), COMMON_TOOLS::ZoomFitScreen(), 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:286

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(), 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(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::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(), 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(), 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 LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), LIB_PIN_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), SCH_MOVE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), PL_EDIT_TOOL::setTransitions(), PAD_TOOL::setTransitions(), FOOTPRINT_EDITOR_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRC::setTransitions(), EDIT_TOOL::setTransitions(), DRAWING_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 439 of file pcbnew_control.cpp.

440 {
442  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
443  return 0;
444 }
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
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(BOARD_ITEM *aItemToCopy, UNDO_REDO_T 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(), m_frame, m_gridOrigin, PCB_BASE_FRAME::SaveCopyInUndoList(), and UR_GRIDORIGIN.

Referenced by setTransitions().

◆ GridSetOrigin()

int PCBNEW_CONTROL::GridSetOrigin ( const TOOL_EVENT aEvent)

Definition at line 403 of file pcbnew_control.cpp.

404 {
405  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
406 
407  if( origin )
408  {
409  // We can't undo the other grid dialog settings, so no sense undoing just the origin
410  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
411  delete origin;
412  }
413  else
414  {
415  if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
416  return 0;
417 
418  std::string tool = aEvent.GetCommandStr().get();
420 
421  // Deactivate other tools; particularly important if another PICKER is currently running
422  Activate();
423 
424  picker->SetClickHandler(
425  [this] ( const VECTOR2D& pt ) -> bool
426  {
428  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
429  return false; // drill origin is a one-shot; don't continue with tool
430  } );
431 
432  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
433  }
434 
435  return 0;
436 }
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
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:149
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
virtual void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
void Activate()
Function Activate() Runs the tool.
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(), 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(), PCBNEW_PICKER_TOOL::SetClickHandler(), and UR_GRIDORIGIN.

Referenced by setTransitions().

◆ HighContrastMode()

int PCBNEW_CONTROL::HighContrastMode ( const TOOL_EVENT aEvent)

Definition at line 213 of file pcbnew_control.cpp.

214 {
215  auto opts = displayOptions();
216 
217  opts.m_ContrastModeDisplay =
218  ( opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL ) ?
221 
222  m_frame->SetDisplayOptions( opts );
223 
224  return 0;
225 }
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 228 of file pcbnew_control.cpp.

229 {
230  auto opts = displayOptions();
231 
232  switch( opts.m_ContrastModeDisplay )
233  {
235  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED;
236  break;
237 
239  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN;
240  break;
241 
243  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
244  break;
245  }
246 
247  m_frame->SetDisplayOptions( opts );
248 
249  // TODO: remove once EVT_UPDATE_UI works
251 
252  return 0;
253 }
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
virtual void SyncToolbars()
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
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, PCB_BASE_FRAME::SetDisplayOptions(), and EDA_BASE_FRAME::SyncToolbars().

Referenced by setTransitions().

◆ Init()

bool PCB_TOOL_BASE::Init ( )
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, GLOBAL_EDIT_TOOL, PAD_TOOL, PCB_INSPECTION_TOOL, and ROUTER_TOOL.

Definition at line 237 of file pcb_tool_base.cpp.

238 {
239  // A basic context manu. Many (but not all) tools will choose to override this.
240 
241  auto& ctxMenu = m_menu.GetMenu();
242 
243  // cancel current tool goes in main context menu at the top if present
245  ctxMenu.AddSeparator( 1 );
246 
247  // Finally, add the standard zoom/grid items
248  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
249 
250  return true;
251 }
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways 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)
Function AddItem()

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 ROUTER_TOOL::onViaCommand().

◆ LayerAlphaDec()

int PCBNEW_CONTROL::LayerAlphaDec ( const TOOL_EVENT aEvent)

Definition at line 365 of file pcbnew_control.cpp.

366 {
367  auto settings = m_frame->GetColorSettings();
368 
369  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
370  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
371 
372  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
373  {
374  currentColor.a -= ALPHA_STEP;
375  settings->SetColor( currentLayer, currentColor );
377 
379  view->UpdateLayerColor( currentLayer );
380 
381  wxUpdateUIEvent dummy;
382  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
383  }
384  else
385  wxBell();
386 
387  return 0;
388 }
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
Type LAYER_NUM 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:777
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 339 of file pcbnew_control.cpp.

340 {
341  auto settings = m_frame->GetColorSettings();
342 
343  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
344  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
345 
346  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
347  {
348  currentColor.a += ALPHA_STEP;
349  settings->SetColor( currentLayer, currentColor );
351 
353  view->UpdateLayerColor( currentLayer );
354 
355  wxUpdateUIEvent dummy;
356  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
357  }
358  else
359  wxBell();
360 
361  return 0;
362 }
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
Type LAYER_NUM 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:777
#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 265 of file pcbnew_control.cpp.

266 {
267  PCB_BASE_FRAME* editFrame = m_frame;
268  BOARD* brd = board();
269  LAYER_NUM layer = editFrame->GetActiveLayer();
270  LAYER_NUM startLayer = layer;
271 
272  if( layer < F_Cu || layer > B_Cu )
273  return 0;
274 
275  while( startLayer != ++layer )
276  {
277  if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
278  break;
279 
280  if( layer >= B_Cu )
281  layer = F_Cu - 1;
282  }
283 
284  wxCHECK( IsCopperLayer( layer ), 0 );
285  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
286 
287  return 0;
288 }
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
Type LAYER_NUM can be replaced with int and removed.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
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 291 of file pcbnew_control.cpp.

292 {
293  PCB_BASE_FRAME* editFrame = m_frame;
294  BOARD* brd = board();
295  LAYER_NUM layer = editFrame->GetActiveLayer();
296  LAYER_NUM startLayer = layer;
297 
298  if( layer < F_Cu || layer > B_Cu )
299  return 0;
300 
301  while( startLayer != --layer )
302  {
303  if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
304  && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
305  break;
306 
307  if( layer <= F_Cu )
308  layer = B_Cu + 1;
309  }
310 
311 
312  wxCHECK( IsCopperLayer( layer ), 0 );
313  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
314 
315  return 0;
316 }
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
Type LAYER_NUM can be replaced with int and removed.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
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 257 of file pcbnew_control.cpp.

258 {
260 
261  return 0;
262 }
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 319 of file pcbnew_control.cpp.

320 {
321  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
322  PCB_SCREEN* screen = m_frame->GetScreen();
323 
324  if( currentLayer == screen->m_Route_Layer_TOP )
326  else
328 
329  return 0;
330 }
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:46
int LAYER_NUM
Type LAYER_NUM 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:45

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 618 of file pcbnew_control.cpp.

619 {
620  CLIPBOARD_IO pi;
621  BOARD_ITEM* clipItem = pi.Parse();
622 
623  if( !clipItem )
624  return 0;
625 
626  bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
627 
628  if( clipItem->Type() == PCB_T )
629  {
630  if( editModules )
631  {
632  for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
633  item->SetNet( NETINFO_LIST::OrphanedItem() );
634  }
635  else
636  static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
637  }
638 
639  // The clipboard can contain two different things, an entire kicad_pcb
640  // or a single module
641 
642  if( editModules && ( !board() || !module() ) )
643  {
644  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
645  return 0;
646  }
647 
648  switch( clipItem->Type() )
649  {
650  case PCB_T:
651  {
652  BOARD* clipBoard = static_cast<BOARD*>( clipItem );
653 
654  if( editModules )
655  {
656  MODULE* editModule = board()->GetFirstModule();
657  std::vector<BOARD_ITEM*> pastedItems;
658 
659  for( MODULE* clipModule : clipBoard->Modules() )
660  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
661 
662  for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
663  {
664  if( clipDrawItem->Type() == PCB_LINE_T )
665  {
666  DRAWSEGMENT* clipDrawSeg = static_cast<DRAWSEGMENT*>( clipDrawItem );
667 
668  // Convert to PCB_MODULE_EDGE_T
669  EDGE_MODULE* pastedDrawSeg = new EDGE_MODULE( editModule );
670  static_cast<DRAWSEGMENT*>( pastedDrawSeg )->SwapData( clipDrawSeg );
671  pastedDrawSeg->SetLocalCoord();
672 
673  pastedItems.push_back( pastedDrawSeg );
674  }
675  else if( clipDrawItem->Type() == PCB_TEXT_T )
676  {
677  TEXTE_PCB* clipTextItem = static_cast<TEXTE_PCB*>( clipDrawItem );
678 
679  // Convert to PCB_MODULE_TEXT_T
680  TEXTE_MODULE* pastedTextItem = new TEXTE_MODULE( editModule );
681  static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
682  static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
683 
684  pastedItems.push_back( pastedTextItem );
685  }
686  }
687 
688  delete clipBoard;
689 
690  placeBoardItems( pastedItems, true, true );
691  }
692  else
693  {
694  placeBoardItems( clipBoard, true );
695 
697  m_frame->Compile_Ratsnest( true );
698  }
699 
700  break;
701  }
702 
703  case PCB_MODULE_T:
704  {
705  MODULE* clipModule = static_cast<MODULE*>( clipItem );
706  std::vector<BOARD_ITEM*> pastedItems;
707 
708  if( editModules )
709  {
710  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
711  delete clipModule;
712  }
713  else
714  {
715  clipModule->SetParent( board() );
716  pastedItems.push_back( clipModule );
717  }
718 
719  placeBoardItems( pastedItems, true, true );
720  break;
721  }
722 
723  default:
724  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
725  break;
726  }
727 
728  return 1;
729 }
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:484
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:266
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:330
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
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
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:275
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 828 of file pcbnew_control.cpp.

830 {
832 
833  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
834  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
835 
836  PCBNEW_SELECTION& selection = selectionTool->GetSelection();
837 
838  for( auto item : aItems )
839  {
840  item->SetSelected();
841  selection.Add( item );
842 
843  // Add or just select items for the move/place command
844  if( aIsNew )
845  editTool->GetCurrentCommit()->Add( item );
846  else
847  editTool->GetCurrentCommit()->Added( item );
848  }
849 
850  if( selection.Size() > 0 )
851  {
852  if( aAnchorAtOrigin )
853  {
855  }
856  else
857  {
858  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
860  }
861 
862  getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
863 
866  }
867 
868  return 0;
869 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
static const TOOL_EVENT SelectedEvent
Definition: actions.h:203
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
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
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:67
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(), EDA_ITEM::GetPosition(), TOOL_MANAGER::GetTool(), PCBNEW_SELECTION::GetTopLeftItem(), TOOL_BASE::getViewControls(), TOOL_BASE::m_toolMgr, PCB_ACTIONS::move, 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 813 of file pcbnew_control.cpp.

814 {
815  // items are new if the current board is not the board source
816  bool isNew = board() != aBoard;
817  std::vector<BOARD_ITEM*> items;
818 
819  moveUnflaggedItems( aBoard->Tracks(), items, isNew );
820  moveUnflaggedItems( aBoard->Modules(), items, isNew );
821  moveUnflaggedItems( aBoard->Drawings(), items, isNew );
822  moveUnflaggedItems( aBoard->Zones(), items, isNew );
823 
824  return placeBoardItems( items, isNew, aAnchorAtOrigin );
825 }
BOARD * board() const
static void moveUnflaggedItems(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
MODULES & Modules()
Definition: class_board.h:266
ZONE_CONTAINERS & Zones()
Definition: class_board.h:280
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:275
TRACKS & Tracks()
Definition: class_board.h:257

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

◆ Print()

int PCBNEW_CONTROL::Print ( const TOOL_EVENT aEvent)

Definition at line 433 of file dialog_print_pcbnew.cpp.

434 {
435  // Selection affects the origin item visibility
437 
439  DIALOG_PRINT_PCBNEW dlg( (PCB_BASE_EDIT_FRAME*) m_frame, &settings );
440 
441  if( m_editModules )
442  dlg.ForcePrintBorder( false );
443 
444  dlg.ShowModal();
445 
446  return 0;
447 }
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 961 of file pcbnew_control.cpp.

962 {
963  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
964  wxCommandEvent dummy;
965 
966  if( editFrame )
967  editFrame->RestoreCopyFromRedoList( dummy );
968 
969  return 0;
970 }
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:361

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:376
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:346
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 275 of file pcb_tool_base.cpp.

276 {
277  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
278  const auto& selection = selTool->GetSelection();
279  return selection;
280 }
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(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), PCB_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), 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(), EDIT_TOOL::Rotate(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), 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 283 of file pcb_tool_base.cpp.

284 {
285  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
286  auto& selection = selTool->GetSelection();
287  return selection;
288 }
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)
Function SetTool() 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(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), 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 1039 of file pcbnew_control.cpp.

1040 {
1043  Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
1044  Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1045 
1046  // Display modes
1057 
1058  // Layer control
1096 
1097  // Grid control
1100 
1101  Go( &PCBNEW_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1102  Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1103 
1104  // Miscellaneous
1106 
1107  // Append control
1109 
1110  Go( &PCBNEW_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1111 
1116 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:268
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:263
static const TOOL_EVENT SelectedEvent
Definition: actions.h:203
static TOOL_ACTION layerNext
Definition: pcb_actions.h:269
int ToggleRatsnest(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:239
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:242
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:204
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:243
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:244
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:245
int AddLibrary(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:258
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:225
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:272
static TOOL_ACTION gridResetOrigin
Definition: actions.h:134
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:231
int HighContrastModeCycle(const TOOL_EVENT &aEvent)
int Quit(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:271
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:230
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:240
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:261
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:248
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
static TOOL_ACTION layerTop
Definition: pcb_actions.h:237
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:260
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:409
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:232
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:250
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:270
int GridResetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:262
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:255
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:267
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:266
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:224
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:247
static const TOOL_EVENT ClearedEvent
Definition: actions.h:205
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:252
static TOOL_ACTION newLibrary
Definition: actions.h:51
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:265
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:264
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:254
int Redo(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:257
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:228
static TOOL_ACTION redo
Definition: actions.h:68
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:259
int LayerAlphaDec(const TOOL_EVENT &aEvent)
int ViaDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:251
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:246
int TrackDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:253
static TOOL_ACTION deleteTool
Definition: actions.h:75
int DeleteItemCursor(const TOOL_EVENT &aEvent)
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:100
int Undo(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:241
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION gridSetOrigin
Definition: actions.h:133
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:256
int LayerSwitch(const TOOL_EVENT &aEvent)
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:238
static TOOL_ACTION highContrastMode
Definition: actions.h:99
static TOOL_ACTION paste
Definition: actions.h:71
int Print(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:226
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:249
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:273
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:229

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 137 of file pcbnew_control.cpp.

138 {
139  auto opts = displayOptions();
140 
141  if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
142  {
143  // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
144  Flip( opts.m_ShowGlobalRatsnest );
145  m_frame->SetDisplayOptions( opts );
146  view()->UpdateDisplayOptions( opts );
147  getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
148  opts.m_ShowGlobalRatsnest );
149 
150  }
151  else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
152  {
153  Flip( opts.m_DisplayRatsnestLinesCurved );
154  m_frame->SetDisplayOptions( opts );
155  view()->UpdateDisplayOptions( opts );
156  }
157 
158  canvas()->RedrawRatsnest();
159  canvas()->Refresh();
160 
161  return 0;
162 }
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:225
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.
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:113
KIGFX::PCB_VIEW * view() const
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:224
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(), PCB_ACTIONS::showRatsnest, KIGFX::PCB_VIEW::UpdateDisplayOptions(), and PCB_TOOL_BASE::view().

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  view()->UpdateDisplayOptions( opts );
124 
125  for( auto track : board()->Tracks() )
126  {
127  if( track->Type() == PCB_TRACE_T )
128  view()->Update( track, KIGFX::GEOMETRY );
129  }
130 
131  canvas()->Refresh();
132 
133  return 0;
134 }
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:91
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.
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:113
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(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), and PCB_TOOL_BASE::view().

Referenced by setTransitions().

◆ Undo()

int PCBNEW_CONTROL::Undo ( const TOOL_EVENT aEvent)

Definition at line 949 of file pcbnew_control.cpp.

950 {
951  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
952  wxCommandEvent dummy;
953 
954  if( editFrame )
955  editFrame->RestoreCopyFromUndoList( dummy );
956 
957  return 0;
958 }
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Function RestoreCopyFromUndoList Undo the last edit:
Definition: undo_redo.cpp:332
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 973 of file pcbnew_control.cpp.

974 {
977 
978  if( selection.GetSize() == 1 )
979  {
980  EDA_ITEM* item = selection.Front();
981  MSG_PANEL_ITEMS msgItems;
982 
983  item->GetMsgPanelInfo( m_frame, msgItems );
984  m_frame->SetMsgPanel( msgItems );
985  }
986  else if( selection.GetSize() > 1 )
987  {
988  MSG_PANEL_ITEMS msgItems;
989  wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
990 
991  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
992  m_frame->SetMsgPanel( msgItems );
993  }
994  else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
995  {
996  MODULE* footprint = static_cast<MODULE*>( editFrame->GetModel() );
997 
998  if( !footprint )
999  return 0;
1000 
1001  MSG_PANEL_ITEMS msgItems;
1002  wxString msg;
1003 
1004  msg = footprint->GetFPID().GetLibNickname().wx_str();
1005  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
1006 
1007  msg = footprint->GetFPID().GetLibItemName().wx_str();
1008  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
1009 
1010  wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
1011 
1012  if( footprint->GetLastEditTime() && date.IsValid() )
1013  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
1014  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
1015  else
1016  msg = _( "Unknown" );
1017 
1018  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
1019 
1020  msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
1021  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
1022 
1023  wxString doc, keyword;
1024  doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
1025  keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
1026  msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
1027 
1028  m_frame->SetMsgPanel( msgItems );
1029  }
1030  else
1031  {
1033  }
1034 
1035  return 0;
1036 }
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:345
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:215
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:221
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:218
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:205
#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 165 of file pcbnew_control.cpp.

166 {
167  auto opts = displayOptions();
168 
169  Flip( opts.m_DisplayViaFill );
170  view()->UpdateDisplayOptions( opts );
171  m_frame->SetDisplayOptions( opts );
172 
173  for( auto track : board()->Tracks() )
174  {
175  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
176  view()->Update( track, KIGFX::GEOMETRY );
177  }
178 
179  canvas()->Refresh();
180 
181  return 0;
182 }
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:91
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.
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:113
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(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), 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(), 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 185 of file pcbnew_control.cpp.

186 {
187  auto opts = displayOptions();
188 
189  // Apply new display options to the GAL canvas
191  opts.m_DisplayZonesMode = 0;
192  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
193  opts.m_DisplayZonesMode = 1;
194  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
195  opts.m_DisplayZonesMode = 2;
196  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
197  opts.m_DisplayZonesMode = ( opts.m_DisplayZonesMode + 1 ) % 3;
198  else
199  wxFAIL;
200 
201  m_frame->SetDisplayOptions( opts );
202  view()->UpdateDisplayOptions( opts );
203 
204  for( int i = 0; i < board()->GetAreaCount(); ++i )
205  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
206 
207  canvas()->Refresh();
208 
209  return 0;
210 }
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:91
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:231
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:230
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
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:232
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:932
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:113
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
Color has changed.
Definition: view_item.h:59
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:229

References PCB_TOOL_BASE::board(), PCB_TOOL_BASE::canvas(), PCB_TOOL_BASE::displayOptions(), KIGFX::GEOMETRY, BOARD::GetAreaCount(), TOOL_EVENT::IsAction(), m_frame, EDA_DRAW_PANEL_GAL::Refresh(), PCB_BASE_FRAME::SetDisplayOptions(), KIGFX::PCB_VIEW::Update(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), 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 118 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(), PICKER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), FOOTPRINT_EDITOR_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::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(), EDIT_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(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), 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 120 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_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(), MICROWAVE_TOOL::createInductorBetween(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), 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(), 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(), 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(), PCB_INSPECTION_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_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(), 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(), 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::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(), DRC::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(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), 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: