KiCad PCB EDA Suite
PCBNEW_CONTROL Class Reference

Class PCBNEW_CONTROL. More...

#include <pcbnew_control.h>

Inheritance diagram for PCBNEW_CONTROL:
PCB_TOOL 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 TrackDisplayMode (const TOOL_EVENT &aEvent)
 
int PadDisplayMode (const TOOL_EVENT &aEvent)
 
int ViaDisplayMode (const TOOL_EVENT &aEvent)
 
int ZoneDisplayMode (const TOOL_EVENT &aEvent)
 
int HighContrastMode (const TOOL_EVENT &aEvent)
 
int HighContrastInc (const TOOL_EVENT &aEvent)
 
int HighContrastDec (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 CursorControl (const TOOL_EVENT &aEvent)
 
int PanControl (const TOOL_EVENT &aEvent)
 
int GridFast1 (const TOOL_EVENT &aEvent)
 
int GridFast2 (const TOOL_EVENT &aEvent)
 
int GridSetOrigin (const TOOL_EVENT &aEvent)
 
int GridResetOrigin (const TOOL_EVENT &aEvent)
 
int ResetCoords (const TOOL_EVENT &aEvent)
 
int SwitchCursor (const TOOL_EVENT &aEvent)
 
int SwitchUnits (const TOOL_EVENT &aEvent)
 
int DeleteItemCursor (const TOOL_EVENT &aEvent)
 
int PasteItemsFromClipboard (const TOOL_EVENT &aEvent)
 
int AppendBoardFromFile (const TOOL_EVENT &aEvent)
 
int AppendBoard (PLUGIN &pi, wxString &fileName)
 
int ShowHelp (const TOOL_EVENT &aEvent)
 
int ToBeDone (const TOOL_EVENT &aEvent)
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_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...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
virtual bool Init ()
 Function Init() Init() is called once upon a registration of the tool. 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...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Member Functions

static bool SetGridOrigin (KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
 
static bool DoSetGridOrigin (KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS {
  IPO_ROTATE = 1, IPO_FLIP = 2, IPO_PROPERTIES = 4, IPO_SINGLE_CLICK = 8,
  IPO_REPEAT = 16
}
 

Protected Member Functions

void doInteractiveItemPlacement (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_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const SELECTIONselection () const
 
SELECTIONselection ()
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
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_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
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

int placeBoardItems (BOARD *aBoard)
 
int placeBoardItems (std::vector< BOARD_ITEM * > &aItems, bool aIsNew)
 add and selec or just select for move/place command a list of board items. More...
 
void updateGrid ()
 

Applies the legacy canvas grid settings for GAL.

More...
 

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...
 

Detailed Description

Class PCBNEW_CONTROL.

Handles actions that are shared between different frames in pcbnew.

Definition at line 44 of file pcbnew_control.h.

Member Enumeration Documentation

enum PCB_TOOL::INTERACTIVE_PLACEMENT_OPTIONS
protectedinherited
Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 104 of file pcb_tool.h.

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 80 of file tool_base.h.

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

Constructor & Destructor Documentation

PCBNEW_CONTROL::PCBNEW_CONTROL ( )

Definition at line 235 of file pcbnew_control.cpp.

References m_gridOrigin.

235  :
236  PCB_TOOL( "pcbnew.Control" ), m_frame( NULL )
237 {
238  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
239 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:69
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
PCBNEW_CONTROL::~PCBNEW_CONTROL ( )

Definition at line 242 of file pcbnew_control.cpp.

243 {
244 }

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

Referenced by EDIT_TOOL::copyToClipboard(), DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), ROUTER_TOOL::SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
int PCBNEW_CONTROL::AppendBoard ( PLUGIN pi,
wxString &  fileName 
)

Definition at line 908 of file pcbnew_control.cpp.

References PCB_TOOL::board(), BOARD::BuildConnectivity(), BOARD::BuildListOfNets(), NETCLASSES::Clear(), DisplayError(), BOARD::Drawings(), FLAG0, Format(), GetChars(), BOARD::GetCopperLayerCount(), PCB_BASE_FRAME::GetDesignSettings(), BOARD::GetEnabledLayers(), PCB_BASE_FRAME::GetPageSizeIU(), PLUGIN::Load(), m_frame, BOARD_DESIGN_SETTINGS::m_NetClasses, PCB_TOOL::module(), BOARD::Modules(), placeBoardItems(), BOARD::SetCopperLayerCount(), BOARD::SetEnabledLayers(), EDA_ITEM::SetFlags(), BOARD::SetVisibleLayers(), BOARD::SynchronizeNetsAndNetClasses(), BOARD::Tracks(), IO_ERROR::What(), and BOARD::Zones().

Referenced by AppendBoardFromFile().

909 {
910  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
911 
912  if( !editFrame )
913  return 1;
914 
915  BOARD* brd = board();
916 
917  if( !brd )
918  return 1;
919 
920  // Mark existing items, in order to know what are the new items
921  // to be ble to select only the new items after loadind
922  for( auto track : brd->Tracks() )
923  {
924  track->SetFlags( FLAG0 );
925  }
926 
927  for( auto module : brd->Modules() )
928  {
929  module->SetFlags( FLAG0 );
930  }
931 
932  for( auto drawing : brd->Drawings() )
933  {
934  drawing->SetFlags( FLAG0 );
935  }
936 
937  for( auto zone : brd->Zones() )
938  {
939  zone->SetFlags( FLAG0 );
940  }
941 
942  // Keep also the count of copper layers, to adjust if necessary
943  int initialCopperLayerCount = brd->GetCopperLayerCount();
944  LSET initialEnabledLayers = brd->GetEnabledLayers();
945 
946  // Load the data
947  try
948  {
949  PROPERTIES props;
950  char xbuf[30];
951  char ybuf[30];
952 
953  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
954  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
955  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
956 
957  props["page_width"] = xbuf;
958  props["page_height"] = ybuf;
959 
960  editFrame->GetDesignSettings().m_NetClasses.Clear();
961  pi.Load( fileName, brd, &props );
962  }
963  catch( const IO_ERROR& ioe )
964  {
965  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
966  DisplayError( editFrame, msg );
967 
968  return 0;
969  }
970 
971  // rebuild nets and ratsnest before any use of nets
972  brd->BuildListOfNets();
974  brd->BuildConnectivity();
975 
976  // Synchronize layers
977  // we should not ask PLUGINs to do these items:
978  int copperLayerCount = brd->GetCopperLayerCount();
979 
980  if( copperLayerCount > initialCopperLayerCount )
981  brd->SetCopperLayerCount( copperLayerCount );
982 
983  // Enable all used layers, and make them visible:
984  LSET enabledLayers = brd->GetEnabledLayers();
985  enabledLayers |= initialEnabledLayers;
986  brd->SetEnabledLayers( enabledLayers );
987  brd->SetVisibleLayers( enabledLayers );
988 
989 
990  return placeBoardItems( brd );
991 }
void BuildListOfNets()
Definition: class_board.h:722
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void SetCopperLayerCount(int aCount)
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
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 ...
Definition: netclass.cpp:158
Class LSET is a set of PCB_LAYER_IDs.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:282
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:250
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
MODULE * module() const
Definition: pcb_tool.h:136
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
int placeBoardItems(BOARD *aBoard)
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:145
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
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:92
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
Definition: netclass.h:249
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
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
const wxSize GetPageSizeIU() const override
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:249
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:74
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:251
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
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:47
BOARD * board() const
Definition: pcb_tool.h:135
int PCBNEW_CONTROL::AppendBoardFromFile ( const TOOL_EVENT aEvent)

Definition at line 816 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

817 {
818  int open_ctl;
819  wxString fileName;
820 
821  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
822 
823  if( !editFrame )
824  return 1;
825 
826  // Pick a file to append
827  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
828  return 1;
829 
830  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
831  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
832 
833  return AppendBoard( *pi, fileName );
834 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Class RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destruct...
Definition: io_mgr.h:556
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, or load design documents.
Definition: io_mgr.cpp:58
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:52
int AppendBoard(PLUGIN &pi, wxString &fileName)
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 59 of file tool_base.cpp.

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155
BOARD* PCB_TOOL::board ( ) const
inlineprotectedinherited

Definition at line 135 of file pcb_tool.h.

Referenced by AppendBoard(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::doInteractiveItemPlacement(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), POINT_EDITOR::finishItem(), SELECTION_TOOL::getCollectorsGuide(), ROUTER_TOOL::getNetclassDimensions(), PAD_TOOL::haveFootprints(), highlightNet(), LayerNext(), LayerPrev(), ROUTER_TOOL::mainLoop(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PadDisplayMode(), PasteItemsFromClipboard(), placeBoardItems(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), Reset(), PNS::TOOL_BASE::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), TrackDisplayMode(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), ViaDisplayMode(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

135 { return getModel<BOARD>(); }
PCB_DRAW_PANEL_GAL * PCB_TOOL::canvas ( ) const
protectedinherited

Definition at line 213 of file pcb_tool.cpp.

References PCB_TOOL::frame(), and EDA_DRAW_FRAME::GetGalCanvas().

Referenced by HighContrastMode(), PadDisplayMode(), TrackDisplayMode(), ViaDisplayMode(), ZoneDisplayMode(), and SELECTION_TOOL::zoomFitSelection().

214 {
215  return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetGalCanvas() );
216 }
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
int PCBNEW_CONTROL::CursorControl ( const TOOL_EVENT aEvent)

Definition at line 480 of file pcbnew_control.cpp.

References BUT_LEFT, ACTIONS::CURSOR_CLICK, ACTIONS::CURSOR_DBL_CLICK, ACTIONS::CURSOR_DOWN, ACTIONS::CURSOR_FAST_MOVE, ACTIONS::CURSOR_LEFT, ACTIONS::CURSOR_RIGHT, ACTIONS::CURSOR_UP, GRID_HELPER::GetGrid(), KIGFX::VIEW_CONTROLS::GetRawCursorPosition(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), KIGFX::VIEW::IsMirroredX(), m_frame, TOOL_BASE::m_toolMgr, MD_ALT, MD_CTRL, MD_SHIFT, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), TOOL_EVENT::SetMousePosition(), TA_MOUSE_CLICK, TA_MOUSE_DBLCLICK, TA_NONE, TC_MOUSE, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

481 {
482  long type = aEvent.Parameter<intptr_t>();
483  bool fastMove = type & PCB_ACTIONS::CURSOR_FAST_MOVE;
484  type &= ~PCB_ACTIONS::CURSOR_FAST_MOVE;
485  bool mirroredX = getView()->IsMirroredX();
486 
487  GRID_HELPER gridHelper( m_frame );
488  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true );
489  VECTOR2I gridSize = gridHelper.GetGrid();
490 
491  if( fastMove )
492  gridSize = gridSize * 10;
493 
494  switch( type )
495  {
497  cursor -= VECTOR2D( 0, gridSize.y );
498  break;
499 
501  cursor += VECTOR2D( 0, gridSize.y );
502  break;
503 
505  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
506  break;
507 
509  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
510  break;
511 
512  case PCB_ACTIONS::CURSOR_CLICK: // fall through
514  {
515  TOOL_ACTIONS action = TA_NONE;
516  int modifiers = 0;
517 
518  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
519  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
520  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
521 
522  if( type == PCB_ACTIONS::CURSOR_CLICK )
523  action = TA_MOUSE_CLICK;
524  else if( type == PCB_ACTIONS::CURSOR_DBL_CLICK )
525  action = TA_MOUSE_DBLCLICK;
526  else
527  assert( false );
528 
529  TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
530  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
531  m_toolMgr->ProcessEvent( evt );
532 
533  return 0;
534  }
535  break;
536  }
537 
538  getViewControls()->SetCursorPosition( cursor );
539 
540  return 0;
541 }
bool IsMirroredX() const
Function IsMirroredX() Returns true if view is flipped across the X axis.
Definition: view.h:227
TOOL_ACTIONS
Definition: tool_event.h:55
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves cursor to the requested position expressed in world coordinates.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
Class TOOL_EVENT.
Definition: tool_event.h:162
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Returns the current cursor position in world coordinates - ingoring the cursorUp position force mode...
int PCBNEW_CONTROL::DeleteItemCursor ( const TOOL_EVENT aEvent)

Definition at line 722 of file pcbnew_control.cpp.

References TOOL_INTERACTIVE::Activate(), deleteItem(), TOOL_MANAGER::GetTool(), ID_PCB_DELETE_ITEM_BUTT, m_frame, TOOL_BASE::m_toolMgr, PICKER_TOOL::SetClickHandler(), PICKER_TOOL::SetSnapping(), PCB_BASE_FRAME::SetToolID(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

723 {
724  Activate();
725 
727  assert( picker );
728 
729  // TODO it will not check the toolbar button in the module editor, as it uses a different ID..
730  m_frame->SetToolID( ID_PCB_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
731  picker->SetSnapping( false );
732  picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) );
733  picker->Activate();
734  Wait();
735 
736  return 0;
737 }
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:56
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:97
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Generic tool for picking a point.
Definition: picker_tool.h:34
static bool deleteItem(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
void Activate()
Function Activate() Runs the tool.
PCB_DISPLAY_OPTIONS * PCB_TOOL::displayOptions ( ) const
protectedinherited

Definition at line 208 of file pcb_tool.cpp.

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

Referenced by HighContrastMode(), PadDisplayMode(), PNS::TOOL_BASE::pickSingleItem(), TrackDisplayMode(), ViaDisplayMode(), and ZoneDisplayMode().

209 {
210  return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
211 }
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
void PCB_TOOL::doInteractiveItemPlacement ( 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 39 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

42 {
43  using namespace std::placeholders;
44  std::unique_ptr<BOARD_ITEM> newItem;
45 
46  Activate();
47 
48  BOARD_COMMIT commit( frame() );
49 
51 
52  // do not capture or auto-pan until we start placing an item
53  controls()->ShowCursor( true );
54  controls()->SetSnapping( true );
55 
56  // Add a VIEW_GROUP that serves as a preview for the new item
57  SELECTION preview;
58  view()->Add( &preview );
59 
60  aPlacer->m_board = board();
61  aPlacer->m_frame = frame();
62 
63  if( aOptions & IPO_SINGLE_CLICK )
64  {
65  VECTOR2I cursorPos = controls()->GetCursorPosition();
66 
67  newItem = aPlacer->CreateItem();
68  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
69 
70  preview.Add( newItem.get() );
71  }
72 
73  // Main loop: keep receiving events
74  while( OPT_TOOL_EVENT evt = Wait() )
75  {
76  VECTOR2I cursorPos = controls()->GetCursorPosition();
77 
79  {
80  if( newItem )
81  {
82  // Delete the old item and have another try
83  newItem = nullptr;
84 
85  preview.Clear();
86 
87  if( aOptions & IPO_SINGLE_CLICK )
88  break;
89 
90  controls()->SetAutoPan( false );
91  controls()->CaptureCursor( false );
92  controls()->ShowCursor( true );
93  }
94  else
95  {
96  break;
97  }
98 
99  if( evt->IsActivate() ) // now finish unconditionally
100  break;
101  }
102 
103  else if( evt->IsClick( BUT_LEFT ) )
104  {
105  if( !newItem )
106  {
107  // create the item if possible
108  newItem = aPlacer->CreateItem();
109 
110  // no item created, so wait for another click
111  if( !newItem )
112  continue;
113 
114  controls()->CaptureCursor( true );
115  controls()->SetAutoPan( true );
116 
117  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
118 
119  preview.Add( newItem.get() );
120 
121  if( newItem->Type() == PCB_MODULE_T )
122  {
123  auto module = dyn_cast<MODULE*>( newItem.get() );
124 
125  // modules have more drawable parts
126  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
127  }
128  }
129  else
130  {
131  newItem->ClearFlags();
132  preview.Remove( newItem.get() );
133 
134  aPlacer->PlaceItem( newItem.get() );
135 
136  if( newItem->Type() == PCB_MODULE_T )
137  {
138  auto module = dyn_cast<MODULE*>( newItem.get() );
139  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
140  }
141 
142  commit.Add( newItem.release() );
143  commit.Push( aCommitMessage );
144 
145  controls()->CaptureCursor( false );
146  controls()->SetAutoPan( false );
147  controls()->ShowCursor( true );
148 
149  if( !( aOptions & IPO_REPEAT ) )
150  break;
151 
152  if( aOptions & IPO_SINGLE_CLICK )
153  {
155 
156  newItem = aPlacer->CreateItem();
157  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
158 
159  preview.Add( newItem.get() );
160  }
161  }
162  }
163 
164  else if( newItem && evt->Category() == TC_COMMAND )
165  {
166  /*
167  * Handle any events that can affect the item as we move
168  * it around, eg rotate and flip
169  */
170 
171  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
172  {
173  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
174  *frame(), *evt );
175  newItem->Rotate( newItem->GetPosition(), rotationAngle );
176  view()->Update( &preview );
177  }
178  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
179  {
180  newItem->Flip( newItem->GetPosition() );
181  view()->Update( &preview );
182  }
183  }
184 
185  else if( newItem && evt->IsMotion() )
186  {
187  // track the cursor
188  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
189 
190  // Show a preview of the item
191  view()->Update( &preview );
192  }
193  }
194 
195  view()->Remove( &preview );
196 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
virtual bool PlaceItem(BOARD_ITEM *aItem)
Definition: pcb_tool.h:55
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
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:81
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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:125
PCB_EDIT_FRAME * m_frame
Definition: pcb_tool.h:57
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:64
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
class MODULE, a footprint
Definition: typeinfo.h:89
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
MODULE * module() const
Definition: pcb_tool.h:136
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
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...
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:102
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool...
Definition: tool_base.h:144
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:48
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
BOARD * board() const
Definition: pcb_tool.h:135
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
bool PCBNEW_CONTROL::DoSetGridOrigin ( KIGFX::VIEW aView,
PCB_BASE_FRAME aFrame,
BOARD_ITEM originViewItem,
const VECTOR2D aPoint 
)
static

Definition at line 601 of file pcbnew_control.cpp.

References KIGFX::VIEW::GetGAL(), KIGFX::VIEW::MarkDirty(), PCB_BASE_FRAME::OnModify(), PCB_BASE_FRAME::SetGridOrigin(), KIGFX::GAL::SetGridOrigin(), BOARD_ITEM::SetPosition(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

603 {
604  aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) );
605  aView->GetGAL()->SetGridOrigin( aPoint );
606  originViewItem->SetPosition( wxPoint( aPoint.x, aPoint.y ) );
607  aView->MarkDirty();
608  aFrame->OnModify();
609  return true;
610 }
virtual void SetPosition(const wxPoint &aPos)=0
void SetGridOrigin(const wxPoint &aPoint) override
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:594
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 97 of file pcb_tool.h.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PAD_TOOL::Init(), and EDIT_TOOL::MeasureTool().

98  {
99  return m_editModules;
100  }
bool m_editModules
Definition: pcb_tool.h:142
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 134 of file pcb_tool.h.

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), PAD_TOOL::applyPadSettings(), PCB_TOOL::canvas(), EDIT_TOOL::changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::displayOptions(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), getMicrowaveItemCreator(), highlightNet(), PICKER_TOOL::Init(), PAD_TOOL::Init(), EDIT_TOOL::Init(), SELECTION_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), ROUTER_TOOL::onViaCommand(), PasteItemsFromClipboard(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), MODULE_EDITOR_TOOLS::PlacePad(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

134 { return getEditFrame<PCB_EDIT_FRAME>(); }
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), and TOOL_SETTINGS::getConfigBase().

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
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 122 of file tool_base.h.

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

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
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 144 of file tool_base.h.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), EDIT_TOOL::MeasureTool(), and CONTEXT_MENU::onMenuEvent().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

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

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:180
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
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 133 of file tool_base.h.

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:214
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

Referenced by GERBVIEW_CONTROL::HighlightControl(), ROUTER_TOOL::Init(), SELECTION_TOOL::selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

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

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
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 35 of file tool_base.cpp.

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

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), GridResetOrigin(), GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), LayerAlphaDec(), LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

36 {
37  return m_toolMgr->GetView();
38 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
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 41 of file tool_base.cpp.

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

Referenced by POINT_EDITOR::addCorner(), CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), ResetCoords(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), EDIT_TOOL::updateModificationPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
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 135 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), POINT_EDITOR::setTransitions(), COMMON_TOOLS::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), PICKER_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), and DRAWING_TOOL::setTransitions().

137 {
138  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
139 
140  goInternal( sptr, aConditions );
141 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
int PCBNEW_CONTROL::GridFast1 ( const TOOL_EVENT aEvent)

Definition at line 583 of file pcbnew_control.cpp.

References m_frame, PCB_BASE_FRAME::SetFastGrid1(), and updateGrid().

Referenced by setTransitions().

584 {
586  updateGrid();
587 
588  return 0;
589 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
void SetFastGrid1()
Function SetFastGrid1()
void updateGrid()
Applies the legacy canvas grid settings for GAL.
int PCBNEW_CONTROL::GridFast2 ( const TOOL_EVENT aEvent)

Definition at line 592 of file pcbnew_control.cpp.

References m_frame, PCB_BASE_FRAME::SetFastGrid2(), and updateGrid().

Referenced by setTransitions().

593 {
595  updateGrid();
596 
597  return 0;
598 }
void SetFastGrid2()
Function SetFastGrid2()
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
void updateGrid()
Applies the legacy canvas grid settings for GAL.
int PCBNEW_CONTROL::GridResetOrigin ( const TOOL_EVENT aEvent)

Definition at line 650 of file pcbnew_control.cpp.

References TOOL_BASE::getView(), m_frame, m_gridOrigin, and SetGridOrigin().

Referenced by setTransitions().

651 {
652  SetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
653 
654  return 0;
655 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
static bool SetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
int PCBNEW_CONTROL::GridSetOrigin ( const TOOL_EVENT aEvent)

Definition at line 621 of file pcbnew_control.cpp.

References TOOL_INTERACTIVE::Activate(), DoSetGridOrigin(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), ID_PCB_PLACE_GRID_COORD_BUTT, m_frame, m_gridOrigin, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), PICKER_TOOL::SetClickHandler(), SetGridOrigin(), PCB_BASE_FRAME::SetToolID(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

622 {
623  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
624 
625  if( origin )
626  {
627  // We can't undo the other grid dialog settings, so no sense undoing just the origin
628 
629  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
630  delete origin;
631  }
632  else
633  {
634  Activate();
635 
637  assert( picker );
638 
639  // TODO it will not check the toolbar button in module editor, as it uses a different ID..
640  m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
641  picker->SetClickHandler( std::bind( SetGridOrigin, getView(), m_frame, m_gridOrigin.get(), _1 ) );
642  picker->Activate();
643  Wait();
644  }
645 
646  return 0;
647 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:97
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Generic tool for picking a point.
Definition: picker_tool.h:34
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
static bool DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
static bool SetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
void Activate()
Function Activate() Runs the tool.
int PCBNEW_CONTROL::HighContrastDec ( const TOOL_EVENT aEvent)

Definition at line 364 of file pcbnew_control.cpp.

Referenced by setTransitions().

365 {
366  return 0;
367 }
int PCBNEW_CONTROL::HighContrastInc ( const TOOL_EVENT aEvent)

Definition at line 358 of file pcbnew_control.cpp.

Referenced by setTransitions().

359 {
360  return 0;
361 }
int PCBNEW_CONTROL::HighContrastMode ( const TOOL_EVENT aEvent)

Definition at line 346 of file pcbnew_control.cpp.

References PCB_TOOL::canvas(), PCB_TOOL::displayOptions(), Flip(), PCB_BASE_FRAME::GetActiveLayer(), m_frame, PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), and PCB_TOOL::view().

Referenced by setTransitions().

347 {
348  auto opts = displayOptions();
349 
350  Flip( opts->m_ContrastModeDisplay );
351  view()->UpdateDisplayOptions( opts );
353 
354  return 0;
355 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:213
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:208
void UpdateDisplayOptions(PCB_DISPLAY_OPTIONS *aOptions)
Definition: pcb_view.cpp:103
virtual void SetHighContrastLayer(int aLayer) override
>
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
void Flip(T &aValue)
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
virtual bool TOOL_BASE::Init ( )
inlinevirtualinherited

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

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

Reimplemented in SELECTION_TOOL, DRAWING_TOOL, GERBVIEW_SELECTION_TOOL, EDIT_TOOL, POSITION_RELATIVE_TOOL, PCB_EDITOR_CONTROL, POINT_EDITOR, MICROWAVE_TOOL, PAD_TOOL, ALIGN_DISTRIBUTE_TOOL, PICKER_TOOL, and ROUTER_TOOL.

Definition at line 93 of file tool_base.h.

Referenced by TOOL_MANAGER::InitTools().

94  {
95  return true;
96  }
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

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

Definition at line 460 of file pcbnew_control.cpp.

References KIGFX::COLOR4D::a, PCB_BASE_FRAME::GetActiveLayer(), EDA_DRAW_FRAME::GetGalCanvas(), KIGFX::VIEW::GetPainter(), KIGFX::PCB_PAINTER::GetSettings(), EDA_DRAW_PANEL_GAL::GetView(), TOOL_BASE::getView(), m_frame, and KIGFX::VIEW::UpdateLayerColor().

Referenced by setTransitions().

461 {
462  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
463  auto settings = painter->GetSettings();
464 
465  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
466  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
467 
468  if( currentColor.a >= 0.05 )
469  {
470  currentColor.a -= 0.05;
471  settings->SetLayerColor( currentLayer, currentColor );
472  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
473  }
474 
475  return 0;
476 }
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:186
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
double a
Alpha component.
Definition: color4d.h:294
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:198
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:654
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
int PCBNEW_CONTROL::LayerAlphaInc ( const TOOL_EVENT aEvent)

Definition at line 441 of file pcbnew_control.cpp.

References KIGFX::COLOR4D::a, PCB_BASE_FRAME::GetActiveLayer(), EDA_DRAW_FRAME::GetGalCanvas(), KIGFX::VIEW::GetPainter(), KIGFX::PCB_PAINTER::GetSettings(), EDA_DRAW_PANEL_GAL::GetView(), TOOL_BASE::getView(), m_frame, and KIGFX::VIEW::UpdateLayerColor().

Referenced by setTransitions().

442 {
443  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
444  auto settings = painter->GetSettings();
445 
446  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
447  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
448 
449  if( currentColor.a <= 0.95 )
450  {
451  currentColor.a += 0.05;
452  settings->SetLayerColor( currentLayer, currentColor );
453  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
454  }
455 
456  return 0;
457 }
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:186
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
double a
Alpha component.
Definition: color4d.h:294
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:198
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:654
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
int PCBNEW_CONTROL::LayerNext ( const TOOL_EVENT aEvent)

Definition at line 379 of file pcbnew_control.cpp.

References B_Cu, PCB_TOOL::board(), F_Cu, PCB_BASE_FRAME::GetActiveLayer(), BOARD::GetCopperLayerCount(), IsCopperLayer(), m_frame, PCB_BASE_FRAME::SwitchLayer(), and ToLAYER_ID().

Referenced by setTransitions().

380 {
381  PCB_BASE_FRAME* editFrame = m_frame;
382  LAYER_NUM layer = editFrame->GetActiveLayer();
383 
384  if( layer < F_Cu || layer > B_Cu )
385  return 0;
386 
387  int layerCount = board()->GetCopperLayerCount();
388 
389  if( layer == layerCount - 2 || layerCount < 2 )
390  layer = B_Cu;
391  else if( layer == B_Cu )
392  layer = F_Cu;
393  else
394  ++layer;
395 
396  assert( IsCopperLayer( layer ) );
397  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
398 
399  return 0;
400 }
int GetCopperLayerCount() const
Function GetCopperLayerCount.
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
BOARD * board() const
Definition: pcb_tool.h:135
int PCBNEW_CONTROL::LayerPrev ( const TOOL_EVENT aEvent)

Definition at line 403 of file pcbnew_control.cpp.

References B_Cu, PCB_TOOL::board(), F_Cu, PCB_BASE_FRAME::GetActiveLayer(), BOARD::GetCopperLayerCount(), IsCopperLayer(), m_frame, PCB_BASE_FRAME::SwitchLayer(), and ToLAYER_ID().

Referenced by setTransitions().

404 {
405  PCB_BASE_FRAME* editFrame = m_frame;
406  LAYER_NUM layer = editFrame->GetActiveLayer();
407 
408  if( layer < F_Cu || layer > B_Cu )
409  return 0;
410 
411  int layerCount = board()->GetCopperLayerCount();
412 
413  if( layer == F_Cu || layerCount < 2 )
414  layer = B_Cu;
415  else if( layer == B_Cu )
416  layer = layerCount - 2;
417  else
418  --layer;
419 
420  assert( IsCopperLayer( layer ) );
421  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
422 
423  return 0;
424 }
int GetCopperLayerCount() const
Function GetCopperLayerCount.
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
BOARD * board() const
Definition: pcb_tool.h:135
int PCBNEW_CONTROL::LayerSwitch ( const TOOL_EVENT aEvent)

Definition at line 371 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

372 {
373  m_frame->SwitchLayer( NULL, (PCB_LAYER_ID) aEvent.Parameter<intptr_t>() );
374 
375  return 0;
376 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
int PCBNEW_CONTROL::LayerToggle ( const TOOL_EVENT aEvent)

Definition at line 427 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

428 {
429  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
430  PCB_SCREEN* screen = m_frame->GetScreen();
431 
432  if( currentLayer == screen->m_Route_Layer_TOP )
433  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_BOTTOM );
434  else
435  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_TOP );
436 
437  return 0;
438 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
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
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
int PCBNEW_CONTROL::PadDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 283 of file pcbnew_control.cpp.

References PCB_TOOL::board(), PCB_TOOL::canvas(), PCB_TOOL::displayOptions(), Flip(), KIGFX::GEOMETRY, PCB_TOOL::module(), MODULE::Pads(), EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::PCB_VIEW::Update(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), and PCB_TOOL::view().

Referenced by setTransitions().

284 {
285  auto opts = displayOptions();
286 
287  Flip( opts->m_DisplayPadFill );
288  view()->UpdateDisplayOptions( opts );
289 
290  for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
291  {
292  for( auto pad : module->Pads() )
293  view()->Update( pad, KIGFX::GEOMETRY );
294  }
295 
296  canvas()->Refresh();
297 
298  return 0;
299 }
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:81
DLIST_ITERATOR_WRAPPER< D_PAD > Pads()
Definition: class_module.h:160
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:213
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:208
MODULE * module() const
Definition: pcb_tool.h:136
void UpdateDisplayOptions(PCB_DISPLAY_OPTIONS *aOptions)
Definition: pcb_view.cpp:103
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:135
int PCBNEW_CONTROL::PanControl ( const TOOL_EVENT aEvent)

Definition at line 544 of file pcbnew_control.cpp.

References ACTIONS::CURSOR_DOWN, ACTIONS::CURSOR_LEFT, ACTIONS::CURSOR_RIGHT, ACTIONS::CURSOR_UP, GRID_HELPER::GetGrid(), TOOL_BASE::getView(), m_frame, TOOL_EVENT::Parameter(), PCB_TOOL::view(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

545 {
546  long type = aEvent.Parameter<intptr_t>();
547  KIGFX::VIEW* view = getView();
548  GRID_HELPER gridHelper( m_frame );
549  VECTOR2D center = view->GetCenter();
550  VECTOR2I gridSize = gridHelper.GetGrid() * 10;
551  bool mirroredX = view->IsMirroredX();
552 
553  switch( type )
554  {
556  center -= VECTOR2D( 0, gridSize.y );
557  break;
558 
560  center += VECTOR2D( 0, gridSize.y );
561  break;
562 
564  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
565  break;
566 
568  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
569  break;
570 
571  default:
572  assert( false );
573  break;
574  }
575 
576  view->SetCenter( center );
577 
578  return 0;
579 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
Class VIEW.
Definition: view.h:58
int PCBNEW_CONTROL::PasteItemsFromClipboard ( const TOOL_EVENT aEvent)

Definition at line 739 of file pcbnew_control.cpp.

References PCB_TOOL::board(), EDA_DRAW_FRAME::DisplayToolMsg(), PCB_TOOL::frame(), FRAME_PCB_MODULE_EDITOR, EDA_BASE_FRAME::IsType(), PCB_TOOL::m_editModules, m_frame, mod, PCB_TOOL::module(), CLIPBOARD_IO::Parse(), PCB_MODULE_T, PCB_T, placeBoardItems(), EDA_ITEM::SetParent(), and EDA_ITEM::Type().

Referenced by setTransitions().

740 {
741  CLIPBOARD_IO pi;
742  BOARD tmpBoard;
743  BOARD_ITEM* clipItem = pi.Parse();
744 
745  if( !clipItem )
746  {
747  return 0;
748  }
749 
750  if( clipItem->Type() == PCB_T )
751  static_cast<BOARD*>(clipItem)->ClearAllNetCodes();
752 
753  bool editModules = m_editModules || frame()->IsType( FRAME_PCB_MODULE_EDITOR );
754 
755  // The clipboard can contain two different things, an entire kicad_pcb
756  // or a single module
757 
758  if( editModules && ( !board() || !module() ) )
759  {
760  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
761  return 0;
762  }
763 
764 
765  switch( clipItem->Type() )
766  {
767  case PCB_T:
768  {
769  if( editModules )
770  {
771  wxLogDebug( wxT( "attempting to paste a pcb in the footprint editor\n") );
772  return 0;
773  }
774 
775  placeBoardItems( static_cast<BOARD*>( clipItem ) );
776  break;
777  }
778 
779  case PCB_MODULE_T:
780  {
781  std::vector<BOARD_ITEM *> items;
782 
783  clipItem->SetParent( board() );
784 
785  if( editModules )
786  {
787  auto mod = static_cast<MODULE *>( clipItem );
788 
789  for( auto pad : mod->Pads() )
790  {
791  pad->SetParent ( board()->m_Modules.GetFirst() );
792  items.push_back( pad );
793  }
794  for( auto item : mod->GraphicalItems() )
795  {
796  item->SetParent ( board()->m_Modules.GetFirst() );
797  items.push_back( item );
798  }
799  }
800  else
801  {
802  items.push_back( clipItem );
803  }
804 
805  placeBoardItems( items, true );
806  break;
807  }
808  default:
809  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
810  // FAILED
811  break;
812  }
813  return 1;
814 }
BOARD_ITEM * Parse()
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
Definition: typeinfo.h:85
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
class MODULE, a footprint
Definition: typeinfo.h:89
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:242
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
MODULE * module() const
Definition: pcb_tool.h:136
int placeBoardItems(BOARD *aBoard)
bool m_editModules
Definition: pcb_tool.h:142
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:511
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
bool IsType(FRAME_T aType) const
#define mod(a, n)
Definition: greymap.cpp:24
BOARD * board() const
Definition: pcb_tool.h:135
int PCBNEW_CONTROL::placeBoardItems ( BOARD aBoard)
private

Definition at line 836 of file pcbnew_control.cpp.

References PCB_TOOL::board(), EDA_ITEM::ClearFlags(), BOARD::Drawings(), FLAG0, EDA_ITEM::GetFlags(), PCB_TOOL::module(), BOARD::Modules(), BOARD::Tracks(), and BOARD::Zones().

Referenced by AppendBoard(), and PasteItemsFromClipboard().

837 {
838  std::vector<BOARD_ITEM*> items;
839 
840  for( auto track : aBoard->Tracks() )
841  {
842  if( track->GetFlags() & FLAG0 )
843  track->ClearFlags( FLAG0 );
844  else
845  items.push_back( track );
846  }
847 
848  for( auto module : aBoard->Modules() )
849  {
850  if( module->GetFlags() & FLAG0 )
851  module->ClearFlags( FLAG0 );
852  else
853  items.push_back( module );
854  }
855 
856  for( auto drawing : aBoard->Drawings() )
857  {
858  if( drawing->GetFlags() & FLAG0 )
859  drawing->ClearFlags( FLAG0 );
860  else
861  items.push_back( drawing );
862  }
863 
864  for( auto zone : aBoard->Zones() )
865  {
866  if( zone->GetFlags() & FLAG0 )
867  zone->ClearFlags( FLAG0 );
868  else
869  items.push_back( zone );
870  }
871 
872  // items are new if the current board is not the board source
873  bool isNew = board() != aBoard;
874  return placeBoardItems( items, isNew );
875 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:284
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:250
MODULE * module() const
Definition: pcb_tool.h:136
int placeBoardItems(BOARD *aBoard)
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:145
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:249
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:251
BOARD * board() const
Definition: pcb_tool.h:135
int PCBNEW_CONTROL::placeBoardItems ( std::vector< BOARD_ITEM * > &  aItems,
bool  aIsNew 
)
private

add and selec 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

Definition at line 878 of file pcbnew_control.cpp.

References SELECTION::Add(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, PCB_ACTIONS::move, TOOL_MANAGER::ProcessEvent(), TOOL_MANAGER::RunAction(), SELECTION_TOOL::SelectedEvent, PCB_TOOL::selection(), and PCB_ACTIONS::selectionClear.

879 {
881 
882  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
883  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
884 
885  SELECTION& selection = selectionTool->GetSelection();
886 
887  for( auto item : aItems )
888  {
889  item->SetSelected();
890  selection.Add( item );
891 
892  // Add or just select items for the move/place command
893  if( aIsNew )
894  editTool->GetCurrentCommit()->Add( item );
895  else
896  editTool->GetCurrentCommit()->Added( item );
897  }
898 
899  selection.SetReferencePoint( VECTOR2I( 0, 0 ) );
900 
903 
904  return 0;
905 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:93
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
Class EDIT_TOOL.
Definition: edit_tool.h:45
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
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.

Definition at line 247 of file pcbnew_control.cpp.

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

248 {
249  m_frame = getEditFrame<PCB_BASE_FRAME>();
250 
251  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
252  {
253  m_gridOrigin->SetPosition( board()->GetGridOrigin() );
254  m_gridOrigin->SetColor( m_frame->GetGridColor() );
255  getView()->Remove( m_gridOrigin.get() );
256  getView()->Add( m_gridOrigin.get() );
257  }
258 }
Model changes (required full reload)
Definition: tool_base.h:83
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:339
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:505
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:309
Rendering engine changes.
Definition: tool_base.h:84
BOARD * board() const
Definition: pcb_tool.h:135
int PCBNEW_CONTROL::ResetCoords ( const TOOL_EVENT aEvent)

Definition at line 659 of file pcbnew_control.cpp.

References KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetScreen(), TOOL_BASE::getViewControls(), m_frame, BASE_SCREEN::m_O_Curseur, PCB_BASE_FRAME::UpdateStatusBar(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

660 {
661  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
662 
663  m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
665 
666  return 0;
667 }
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
virtual void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
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 85 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
const SELECTION & PCB_TOOL::selection ( ) const
protectedinherited

Definition at line 218 of file pcb_tool.cpp.

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

Referenced by PAD_TOOL::applyPadSettings(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), deleteItem(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), EDIT_TOOL::Rotate(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), SELECTION_TOOL::selectNet(), selectPRitem(), showLocalRatsnest(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

219 {
220  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
221  const auto& selection = selTool->GetSelection();
222  return selection;
223 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
SELECTION & PCB_TOOL::selection ( )
protectedinherited

Definition at line 225 of file pcb_tool.cpp.

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

226 {
227  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
228  auto& selection = selTool->GetSelection();
229  return selection;
230 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_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 74 of file tool_interactive.cpp.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), and TOOL_MENU::ShowContextMenu().

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool&#39;s context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void PCB_TOOL::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 92 of file pcb_tool.h.

93  {
94  m_editModules = aEnabled;
95  }
bool m_editModules
Definition: pcb_tool.h:142
bool PCBNEW_CONTROL::SetGridOrigin ( KIGFX::VIEW aView,
PCB_BASE_FRAME aFrame,
BOARD_ITEM originViewItem,
const VECTOR2D aPoint 
)
static

Definition at line 613 of file pcbnew_control.cpp.

References DoSetGridOrigin(), PCB_BASE_FRAME::SaveCopyInUndoList(), and UR_GRIDORIGIN.

Referenced by GridResetOrigin(), GridSetOrigin(), FOOTPRINT_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnHotKey(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), and PCB_EDIT_FRAME::OnLeftClick().

615 {
616  aFrame->SaveCopyInUndoList( originViewItem, UR_GRIDORIGIN );
617  return DoSetGridOrigin( aView, aFrame, originViewItem, aPoint );
618 }
static bool DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
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 PCBNEW_CONTROL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL.

Definition at line 1010 of file pcbnew_control.cpp.

References PCB_ACTIONS::appendBoard, AppendBoardFromFile(), PCB_ACTIONS::cursorClick, CursorControl(), PCB_ACTIONS::cursorDblClick, PCB_ACTIONS::cursorDown, PCB_ACTIONS::cursorDownFast, PCB_ACTIONS::cursorLeft, PCB_ACTIONS::cursorLeftFast, PCB_ACTIONS::cursorRight, PCB_ACTIONS::cursorRightFast, PCB_ACTIONS::cursorUp, PCB_ACTIONS::cursorUpFast, DeleteItemCursor(), PCB_ACTIONS::deleteItemCursor, TOOL_INTERACTIVE::Go(), ACTIONS::gridFast1, GridFast1(), ACTIONS::gridFast2, GridFast2(), ACTIONS::gridResetOrigin, GridResetOrigin(), ACTIONS::gridSetOrigin, GridSetOrigin(), HighContrastDec(), PCB_ACTIONS::highContrastDec, HighContrastInc(), PCB_ACTIONS::highContrastInc, HighContrastMode(), PCB_ACTIONS::highContrastMode, LayerAlphaDec(), PCB_ACTIONS::layerAlphaDec, LayerAlphaInc(), PCB_ACTIONS::layerAlphaInc, PCB_ACTIONS::layerBottom, PCB_ACTIONS::layerInner1, PCB_ACTIONS::layerInner2, PCB_ACTIONS::layerInner3, PCB_ACTIONS::layerInner4, PCB_ACTIONS::layerInner5, PCB_ACTIONS::layerInner6, LayerNext(), PCB_ACTIONS::layerNext, LayerPrev(), PCB_ACTIONS::layerPrev, LayerSwitch(), LayerToggle(), PCB_ACTIONS::layerToggle, PCB_ACTIONS::layerTop, PadDisplayMode(), PCB_ACTIONS::padDisplayMode, PanControl(), PCB_ACTIONS::panDown, PCB_ACTIONS::panLeft, PCB_ACTIONS::panRight, PCB_ACTIONS::panUp, PCB_ACTIONS::pasteFromClipboard, PasteItemsFromClipboard(), ResetCoords(), PCB_ACTIONS::resetCoords, ShowHelp(), PCB_ACTIONS::showHelp, SwitchCursor(), PCB_ACTIONS::switchCursor, SwitchUnits(), PCB_ACTIONS::switchUnits, ToBeDone(), PCB_ACTIONS::toBeDone, TrackDisplayMode(), PCB_ACTIONS::trackDisplayMode, ViaDisplayMode(), PCB_ACTIONS::viaDisplayMode, PCB_ACTIONS::zoneDisplayDisable, PCB_ACTIONS::zoneDisplayEnable, ZoneDisplayMode(), and PCB_ACTIONS::zoneDisplayOutlines.

1011 {
1012  // Display modes
1022 
1023  // Layer control
1037 
1038  // Cursor control
1049 
1050  // Pan control
1055 
1056  // Grid control
1061 
1062  // Miscellaneous
1069 
1070  // Append control
1072  PCB_ACTIONS::appendBoard.MakeEvent() );
1073 
1075  PCB_ACTIONS::pasteFromClipboard.MakeEvent() );
1076 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:275
int SwitchCursor(const TOOL_EVENT &aEvent)
int PanControl(const TOOL_EVENT &aEvent)
int PadDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorUpFast
Definition: pcb_actions.h:357
static TOOL_ACTION layerNext
Definition: pcb_actions.h:276
int HighContrastInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:270
static TOOL_ACTION cursorDblClick
Definition: pcb_actions.h:363
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:273
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:274
static TOOL_ACTION showHelp
Definition: pcb_actions.h:389
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:279
static TOOL_ACTION gridResetOrigin
Definition: actions.h:66
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:262
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:278
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:261
int HighContrastMode(const TOOL_EVENT &aEvent)
int LayerPrev(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridFast1
Definition: actions.h:61
int GridSetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: pcb_actions.h:352
static TOOL_ACTION pasteFromClipboard
Paste from clipboard.
Definition: pcb_actions.h:319
static TOOL_ACTION switchUnits
Definition: pcb_actions.h:382
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:271
int LayerNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION deleteItemCursor
Definition: pcb_actions.h:383
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION resetCoords
Definition: pcb_actions.h:379
static TOOL_ACTION layerTop
Definition: pcb_actions.h:268
static TOOL_ACTION highContrastMode
Definition: pcb_actions.h:263
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:388
static TOOL_ACTION gridFast2
Definition: actions.h:62
static TOOL_ACTION cursorRightFast
Definition: pcb_actions.h:360
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:277
static TOOL_ACTION toBeDone
Definition: pcb_actions.h:391
int GridResetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION panRight
Definition: pcb_actions.h:369
static TOOL_ACTION cursorClick
Definition: pcb_actions.h:362
int LayerToggle(const TOOL_EVENT &aEvent)
static TOOL_ACTION panUp
Definition: pcb_actions.h:366
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
int GridFast1(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorRight
Definition: pcb_actions.h:355
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION panLeft
Definition: pcb_actions.h:368
int ResetCoords(const TOOL_EVENT &aEvent)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:258
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:259
int ShowHelp(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorLeft
Definition: pcb_actions.h:354
int LayerAlphaDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION highContrastInc
Definition: pcb_actions.h:264
static TOOL_ACTION switchCursor
Definition: pcb_actions.h:381
int ViaDisplayMode(const TOOL_EVENT &aEvent)
int TrackDisplayMode(const TOOL_EVENT &aEvent)
int SwitchUnits(const TOOL_EVENT &aEvent)
int DeleteItemCursor(const TOOL_EVENT &aEvent)
int CursorControl(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:272
int GridFast2(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorDown
Definition: pcb_actions.h:353
static TOOL_ACTION gridSetOrigin
Definition: actions.h:65
static TOOL_ACTION cursorLeftFast
Definition: pcb_actions.h:359
int ToBeDone(const TOOL_EVENT &aEvent)
int LayerSwitch(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:269
static TOOL_ACTION panDown
Definition: pcb_actions.h:367
int PasteItemsFromClipboard(const TOOL_EVENT &aEvent)
static TOOL_ACTION highContrastDec
Definition: pcb_actions.h:265
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:257
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:280
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:260
int HighContrastDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorDownFast
Definition: pcb_actions.h:358
int PCBNEW_CONTROL::ShowHelp ( const TOOL_EVENT aEvent)

Definition at line 994 of file pcbnew_control.cpp.

References DisplayHotkeyList(), EDA_DRAW_FRAME::GetHotkeyConfig(), and m_frame.

Referenced by setTransitions().

995 {
997 
998  return 0;
999 }
EDA_HOTKEY_CONFIG * GetHotkeyConfig() const
Function GetHotkeyConfig() Returns a structure containing currently used hotkey mapping.
Definition: draw_frame.h:388
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
int PCBNEW_CONTROL::SwitchCursor ( const TOOL_EVENT aEvent)

Definition at line 670 of file pcbnew_control.cpp.

References EDA_DRAW_FRAME::GetGalDisplayOptions(), m_frame, and KIGFX::GAL_DISPLAY_OPTIONS::m_fullscreenCursor.

Referenced by setTransitions().

671 {
672  auto& galOpts = m_frame->GetGalDisplayOptions();
673 
674  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
675  galOpts.NotifyChanged();
676 
677  return 0;
678 }
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:903
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
bool m_fullscreenCursor
Fullscreen crosshair or small cross
int PCBNEW_CONTROL::SwitchUnits ( const TOOL_EVENT aEvent)

Definition at line 681 of file pcbnew_control.cpp.

References g_UserUnit, ID_TB_OPTIONS_SELECT_UNIT_INCH, ID_TB_OPTIONS_SELECT_UNIT_MM, INCHES, m_frame, and EDA_BASE_FRAME::ProcessEvent().

Referenced by setTransitions().

682 {
683  // TODO should not it be refactored to pcb_frame member function?
684  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
685 
686  if( g_UserUnit == INCHES )
687  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
688  else
689  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
690 
691  m_frame->ProcessEvent( evt );
692 
693  return 0;
694 }
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:122
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common.h:145
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
int PCBNEW_CONTROL::ToBeDone ( const TOOL_EVENT aEvent)

Definition at line 1002 of file pcbnew_control.cpp.

References DisplayInfoMessage(), and m_frame.

Referenced by setTransitions().

1003 {
1004  DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) );
1005 
1006  return 0;
1007 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:105
int PCBNEW_CONTROL::TrackDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 265 of file pcbnew_control.cpp.

References PCB_TOOL::board(), PCB_TOOL::canvas(), PCB_TOOL::displayOptions(), Flip(), KIGFX::GEOMETRY, PCB_TRACE_T, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::PCB_VIEW::Update(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), and PCB_TOOL::view().

Referenced by setTransitions().

266 {
267  auto opts = displayOptions();
268 
269  Flip( opts->m_DisplayPcbTrackFill );
270  view()->UpdateDisplayOptions( opts );
271 
272  for( auto track : board()->Tracks() )
273  {
274  if( track->Type() == PCB_TRACE_T )
275  view()->Update( track, KIGFX::GEOMETRY );
276  }
277 
278  canvas()->Refresh();
279 
280  return 0;
281 }
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:81
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:213
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:208
void UpdateDisplayOptions(PCB_DISPLAY_OPTIONS *aOptions)
Definition: pcb_view.cpp:103
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:135
void PCBNEW_CONTROL::updateGrid ( )
private

Applies the legacy canvas grid settings for GAL.

Definition at line 1079 of file pcbnew_control.cpp.

References KIGFX::VIEW::GetGAL(), BASE_SCREEN::GetGridSize(), PCB_BASE_FRAME::GetScreen(), TOOL_BASE::getView(), m_frame, KIGFX::VIEW::MarkTargetDirty(), KIGFX::GAL::SetGridSize(), and KIGFX::TARGET_NONCACHED.

Referenced by GridFast1(), and GridFast2().

1080 {
1081  BASE_SCREEN* screen = m_frame->GetScreen();
1082  //GRID_TYPE grid = screen->GetGrid( idx );
1083  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
1085 }
Auxiliary rendering target (noncached)
Definition: definitions.h:42
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:568
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
int PCBNEW_CONTROL::ViaDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 302 of file pcbnew_control.cpp.

References PCB_TOOL::board(), PCB_TOOL::canvas(), PCB_TOOL::displayOptions(), Flip(), KIGFX::GEOMETRY, PCB_TRACE_T, PCB_VIA_T, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::PCB_VIEW::Update(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), and PCB_TOOL::view().

Referenced by setTransitions().

303 {
304  auto opts = displayOptions();
305 
306  Flip( opts->m_DisplayViaFill );
307  view()->UpdateDisplayOptions( opts );
308 
309  for( auto track : board()->Tracks() )
310  {
311  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
312  view()->Update( track, KIGFX::GEOMETRY );
313  }
314 
315  canvas()->Refresh();
316 
317  return 0;
318 }
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:81
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:213
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:208
void UpdateDisplayOptions(PCB_DISPLAY_OPTIONS *aOptions)
Definition: pcb_view.cpp:103
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:135
OPT_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 55 of file tool_interactive.cpp.

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

Referenced by DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT< 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.
int PCBNEW_CONTROL::ZoneDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 321 of file pcbnew_control.cpp.

References PCB_TOOL::board(), PCB_TOOL::canvas(), PCB_TOOL::displayOptions(), KIGFX::GEOMETRY, BOARD::GetAreaCount(), TOOL_EVENT::IsAction(), EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::PCB_VIEW::Update(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), PCB_TOOL::view(), PCB_ACTIONS::zoneDisplayDisable, PCB_ACTIONS::zoneDisplayEnable, and PCB_ACTIONS::zoneDisplayOutlines.

Referenced by setTransitions().

322 {
323  auto opts = displayOptions();
324 
325  // Apply new display options to the GAL canvas
327  opts->m_DisplayZonesMode = 0;
328  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
329  opts->m_DisplayZonesMode = 1;
330  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
331  opts->m_DisplayZonesMode = 2;
332  else
333  assert( false );
334 
335  view()->UpdateDisplayOptions( opts );
336 
337  for( int i = 0; i < board()->GetAreaCount(); ++i )
338  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
339 
340  canvas()->Refresh();
341 
342  return 0;
343 }
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:81
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:262
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:261
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:54
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:213
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:208
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1011
void UpdateDisplayOptions(PCB_DISPLAY_OPTIONS *aOptions)
Definition: pcb_view.cpp:103
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:135
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:260

Member Data Documentation

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

Grid origin marker.

Definition at line 115 of file pcbnew_control.h.

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

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), PICKER_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), placeBoardItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), GERBVIEW_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EDIT_TOOL::updateModificationPoint(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

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 214 of file tool_base.h.

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_BASE::attachManager().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.


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