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 ZoneDisplayMode (const TOOL_EVENT &aEvent)
 
int TrackDisplayMode (const TOOL_EVENT &aEvent)
 
int PadDisplayMode (const TOOL_EVENT &aEvent)
 
int ViaDisplayMode (const TOOL_EVENT &aEvent)
 
int GraphicDisplayMode (const TOOL_EVENT &aEvent)
 
int ModuleEdgeOutlines (const TOOL_EVENT &aEvent)
 
int ModuleTextOutlines (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 105 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 247 of file pcbnew_control.cpp.

References m_gridOrigin.

247  :
248  PCB_TOOL( "pcbnew.Control" ), m_frame( NULL )
249 {
250  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
251 }
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:70
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
PCBNEW_CONTROL::~PCBNEW_CONTROL ( )

Definition at line 254 of file pcbnew_control.cpp.

255 {
256 }

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 996 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().

997 {
998  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
999 
1000  if( !editFrame )
1001  return 1;
1002 
1003  BOARD* brd = board();
1004 
1005  if( !brd )
1006  return 1;
1007 
1008  // Mark existing items, in order to know what are the new items
1009  // to be ble to select only the new items after loadind
1010  for( auto track : brd->Tracks() )
1011  {
1012  track->SetFlags( FLAG0 );
1013  }
1014 
1015  for( auto module : brd->Modules() )
1016  {
1017  module->SetFlags( FLAG0 );
1018  }
1019 
1020  for( auto drawing : brd->Drawings() )
1021  {
1022  drawing->SetFlags( FLAG0 );
1023  }
1024 
1025  for( auto zone : brd->Zones() )
1026  {
1027  zone->SetFlags( FLAG0 );
1028  }
1029 
1030  // Keep also the count of copper layers, to adjust if necessary
1031  int initialCopperLayerCount = brd->GetCopperLayerCount();
1032  LSET initialEnabledLayers = brd->GetEnabledLayers();
1033 
1034  // Load the data
1035  try
1036  {
1037  PROPERTIES props;
1038  char xbuf[30];
1039  char ybuf[30];
1040 
1041  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
1042  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
1043  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
1044 
1045  props["page_width"] = xbuf;
1046  props["page_height"] = ybuf;
1047 
1048  editFrame->GetDesignSettings().m_NetClasses.Clear();
1049  pi.Load( fileName, brd, &props );
1050  }
1051  catch( const IO_ERROR& ioe )
1052  {
1053  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
1054  DisplayError( editFrame, msg );
1055 
1056  return 0;
1057  }
1058 
1059  // rebuild nets and ratsnest before any use of nets
1060  brd->BuildListOfNets();
1062  brd->BuildConnectivity();
1063 
1064  // Synchronize layers
1065  // we should not ask PLUGINs to do these items:
1066  int copperLayerCount = brd->GetCopperLayerCount();
1067 
1068  if( copperLayerCount > initialCopperLayerCount )
1069  brd->SetCopperLayerCount( copperLayerCount );
1070 
1071  // Enable all used layers, and make them visible:
1072  LSET enabledLayers = brd->GetEnabledLayers();
1073  enabledLayers |= initialEnabledLayers;
1074  brd->SetEnabledLayers( enabledLayers );
1075  brd->SetVisibleLayers( enabledLayers );
1076 
1077 
1078  return placeBoardItems( brd );
1079 }
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:264
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:137
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:127
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:185
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:136
int PCBNEW_CONTROL::AppendBoardFromFile ( const TOOL_EVENT aEvent)

Definition at line 904 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

905 {
906  int open_ctl;
907  wxString fileName;
908 
909  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
910 
911  if( !editFrame )
912  return 1;
913 
914  // Pick a file to append
915  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
916  return 1;
917 
918  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
919  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
920 
921  return AppendBoard( *pi, fileName );
922 }
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:563
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 136 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(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), POINT_EDITOR::finishItem(), SELECTION_TOOL::getCollectorsGuide(), ROUTER_TOOL::getNetclassDimensions(), GraphicDisplayMode(), PAD_TOOL::haveFootprints(), highlightNet(), LayerNext(), LayerPrev(), ROUTER_TOOL::mainLoop(), ModuleEdgeOutlines(), ModuleTextOutlines(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PadDisplayMode(), PasteItemsFromClipboard(), placeBoardItems(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), 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().

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

Definition at line 214 of file pcb_tool.cpp.

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

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

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

Definition at line 573 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().

574 {
575  long type = aEvent.Parameter<intptr_t>();
576  bool fastMove = type & PCB_ACTIONS::CURSOR_FAST_MOVE;
577  type &= ~PCB_ACTIONS::CURSOR_FAST_MOVE;
578  bool mirroredX = getView()->IsMirroredX();
579 
580  GRID_HELPER gridHelper( m_frame );
581  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true );
582  VECTOR2I gridSize = gridHelper.GetGrid();
583 
584  if( fastMove )
585  gridSize = gridSize * 10;
586 
587  switch( type )
588  {
590  cursor -= VECTOR2D( 0, gridSize.y );
591  break;
592 
594  cursor += VECTOR2D( 0, gridSize.y );
595  break;
596 
598  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
599  break;
600 
602  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
603  break;
604 
605  case PCB_ACTIONS::CURSOR_CLICK: // fall through
607  {
608  TOOL_ACTIONS action = TA_NONE;
609  int modifiers = 0;
610 
611  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
612  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
613  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
614 
615  if( type == PCB_ACTIONS::CURSOR_CLICK )
616  action = TA_MOUSE_CLICK;
617  else if( type == PCB_ACTIONS::CURSOR_DBL_CLICK )
618  action = TA_MOUSE_DBLCLICK;
619  else
620  assert( false );
621 
622  TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
623  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
624  m_toolMgr->ProcessEvent( evt );
625 
626  return 0;
627  }
628  break;
629  }
630 
631  getViewControls()->SetCursorPosition( cursor );
632 
633  return 0;
634 }
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 810 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().

811 {
812  Activate();
813 
815  assert( picker );
816 
817  // TODO it will not check the toolbar button in the module editor, as it uses a different ID..
818  m_frame->SetToolID( ID_PCB_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
819  picker->SetSnapping( false );
820  picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) );
821  picker->Activate();
822  Wait();
823 
824  return 0;
825 }
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 209 of file pcb_tool.cpp.

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

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

210 {
211  return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
212 }
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:135
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(), 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(), INTERACTIVE_PLACER_BASE::SnapItem(), 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(), commit );
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  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  aPlacer->SnapItem( newItem.get() );
190 
191  // Show a preview of the item
192  view()->Update( &preview );
193  }
194  }
195 
196  view()->Remove( &preview );
197 }
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 PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Definition: pcb_tool.cpp:239
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:84
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:58
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:74
virtual void SnapItem(BOARD_ITEM *aItem)
Definition: pcb_tool.cpp:234
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:134
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:135
MODULE * module() const
Definition: pcb_tool.h:137
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:133
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:136
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:79
bool PCBNEW_CONTROL::DoSetGridOrigin ( KIGFX::VIEW aView,
PCB_BASE_FRAME aFrame,
BOARD_ITEM originViewItem,
const VECTOR2D aPoint 
)
static

Definition at line 694 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().

696 {
697  aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) );
698  aView->GetGAL()->SetGridOrigin( aPoint );
699  originViewItem->SetPosition( wxPoint( aPoint.x, aPoint.y ) );
700  aView->MarkDirty();
701  aFrame->OnModify();
702  return true;
703 }
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:603
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 98 of file pcb_tool.h.

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

99  {
100  return m_editModules;
101  }
bool m_editModules
Definition: pcb_tool.h:143
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 135 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(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), 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(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PasteItemsFromClipboard(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), MODULE_EDITOR_TOOLS::PlacePad(), DRAWING_TOOL::PlaceText(), 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(), POINT_EDITOR::updateItem(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

135 { 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:162
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(), PCB_EDITOR_CONTROL::HighlightNetCursor(), 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(), GERBVIEW_CONTROL::ResetCoords(), 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(), POINT_EDITOR::setTransitions(), COMMON_TOOLS::setTransitions(), GERBVIEW_CONTROL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), 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::GraphicDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 333 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

334 {
335  auto opts = displayOptions();
336 
337  Flip( opts->m_DisplayDrawItemsFill );
338  view()->UpdateDisplayOptions( opts );
339 
340  for( auto item : board()->Drawings() )
341  {
342  view()->Update( item, KIGFX::GEOMETRY );
343  }
344 
345  canvas()->Refresh();
346 
347  return 0;
348 }
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
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
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:133
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:136
int PCBNEW_CONTROL::GridFast1 ( const TOOL_EVENT aEvent)

Definition at line 676 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

677 {
679  updateGrid();
680 
681  return 0;
682 }
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 685 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

686 {
688  updateGrid();
689 
690  return 0;
691 }
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 743 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

744 {
745  SetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
746 
747  return 0;
748 }
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 714 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().

715 {
716  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
717 
718  if( origin )
719  {
720  // We can't undo the other grid dialog settings, so no sense undoing just the origin
721 
722  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
723  delete origin;
724  }
725  else
726  {
727  Activate();
728 
730  assert( picker );
731 
732  // TODO it will not check the toolbar button in module editor, as it uses a different ID..
733  m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
734  picker->SetClickHandler( std::bind( SetGridOrigin, getView(), m_frame, m_gridOrigin.get(), _1 ) );
735  picker->Activate();
736  Wait();
737  }
738 
739  return 0;
740 }
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 441 of file pcbnew_control.cpp.

Referenced by setTransitions().

442 {
443  return 0;
444 }
int PCBNEW_CONTROL::HighContrastInc ( const TOOL_EVENT aEvent)

Definition at line 435 of file pcbnew_control.cpp.

Referenced by setTransitions().

436 {
437  return 0;
438 }
int PCBNEW_CONTROL::HighContrastMode ( const TOOL_EVENT aEvent)

Definition at line 423 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().

424 {
425  auto opts = displayOptions();
426 
427  Flip( opts->m_ContrastModeDisplay );
428  view()->UpdateDisplayOptions( opts );
430 
431  return 0;
432 }
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
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:133
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 548 of file pcbnew_control.cpp.

References KIGFX::COLOR4D::a, ALPHA_MIN, ALPHA_STEP, dummy(), 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().

549 {
550  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
551  auto settings = painter->GetSettings();
552 
553  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
554  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
555 
556  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
557  {
558  currentColor.a -= ALPHA_STEP;
559  settings->SetLayerColor( currentLayer, currentColor );
560  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
561 
562  wxUpdateUIEvent dummy;
563  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
564  }
565  else
566  wxBell();
567 
568  return 0;
569 }
#define ALPHA_MIN
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
#define ALPHA_STEP
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:725
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:895
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
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 524 of file pcbnew_control.cpp.

References KIGFX::COLOR4D::a, ALPHA_MAX, ALPHA_STEP, dummy(), 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().

525 {
526  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
527  auto settings = painter->GetSettings();
528 
529  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
530  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
531 
532  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
533  {
534  currentColor.a += ALPHA_STEP;
535  settings->SetLayerColor( currentLayer, currentColor );
536  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
537 
538  wxUpdateUIEvent dummy;
539  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
540  }
541  else
542  wxBell();
543 
544  return 0;
545 }
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
#define ALPHA_STEP
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:725
#define ALPHA_MAX
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:895
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 456 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().

457 {
458  PCB_BASE_FRAME* editFrame = m_frame;
459  LAYER_NUM layer = editFrame->GetActiveLayer();
460 
461  if( layer < F_Cu || layer > B_Cu )
462  return 0;
463 
464  int layerCount = board()->GetCopperLayerCount();
465 
466  if( layer == layerCount - 2 || layerCount < 2 )
467  layer = B_Cu;
468  else if( layer == B_Cu )
469  layer = F_Cu;
470  else
471  ++layer;
472 
473  assert( IsCopperLayer( layer ) );
474  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
475 
476  return 0;
477 }
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:136
int PCBNEW_CONTROL::LayerPrev ( const TOOL_EVENT aEvent)

Definition at line 480 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().

481 {
482  PCB_BASE_FRAME* editFrame = m_frame;
483  LAYER_NUM layer = editFrame->GetActiveLayer();
484 
485  if( layer < F_Cu || layer > B_Cu )
486  return 0;
487 
488  int layerCount = board()->GetCopperLayerCount();
489 
490  if( layer == F_Cu || layerCount < 2 )
491  layer = B_Cu;
492  else if( layer == B_Cu )
493  layer = layerCount - 2;
494  else
495  --layer;
496 
497  assert( IsCopperLayer( layer ) );
498  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
499 
500  return 0;
501 }
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:136
int PCBNEW_CONTROL::LayerSwitch ( const TOOL_EVENT aEvent)

Definition at line 448 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

449 {
450  m_frame->SwitchLayer( NULL, (PCB_LAYER_ID) aEvent.Parameter<intptr_t>() );
451 
452  return 0;
453 }
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 504 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().

505 {
506  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
507  PCB_SCREEN* screen = m_frame->GetScreen();
508 
509  if( currentLayer == screen->m_Route_Layer_TOP )
510  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_BOTTOM );
511  else
512  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_TOP );
513 
514  return 0;
515 }
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::ModuleEdgeOutlines ( const TOOL_EVENT aEvent)

Definition at line 351 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

352 {
353  auto opts = displayOptions();
354 
355  Flip( opts->m_DisplayModEdgeFill );
356  view()->UpdateDisplayOptions( opts );
357 
358  for( auto module : board()->Modules() )
359  {
360  for( auto item : module->GraphicalItems() )
361  {
362  if( item->Type() == PCB_MODULE_EDGE_T )
363  view()->Update( item, KIGFX::GEOMETRY );
364  }
365  }
366 
367  canvas()->Refresh();
368 
369  return 0;
370 }
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 EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > GraphicalItems()
Definition: class_module.h:172
MODULE * module() const
Definition: pcb_tool.h:137
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:133
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:136
int PCBNEW_CONTROL::ModuleTextOutlines ( const TOOL_EVENT aEvent)

Definition at line 373 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

374 {
375  auto opts = displayOptions();
376 
377  Flip( opts->m_DisplayModTextFill );
378  view()->UpdateDisplayOptions( opts );
379 
380  for( auto module : board()->Modules() )
381  {
382  for( auto item : module->GraphicalItems() )
383  {
384  if( item->Type() == PCB_MODULE_TEXT_T )
385  view()->Update( item, KIGFX::GEOMETRY );
386  }
387 
390  }
391 
392  canvas()->Refresh();
393 
394  return 0;
395 }
TEXTE_MODULE & Reference()
Definition: class_module.h:502
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
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > GraphicalItems()
Definition: class_module.h:172
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
MODULE * module() const
Definition: pcb_tool.h:137
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...
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:133
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:136
int PCBNEW_CONTROL::PadDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 295 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().

296 {
297  auto opts = displayOptions();
298 
299  Flip( opts->m_DisplayPadFill );
300  view()->UpdateDisplayOptions( opts );
301 
302  for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
303  {
304  for( auto pad : module->Pads() )
305  view()->Update( pad, KIGFX::GEOMETRY );
306  }
307 
308  canvas()->Refresh();
309 
310  return 0;
311 }
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:167
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
MODULE * module() const
Definition: pcb_tool.h:137
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:133
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:136
int PCBNEW_CONTROL::PanControl ( const TOOL_EVENT aEvent)

Definition at line 637 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().

638 {
639  long type = aEvent.Parameter<intptr_t>();
640  KIGFX::VIEW* view = getView();
641  GRID_HELPER gridHelper( m_frame );
642  VECTOR2D center = view->GetCenter();
643  VECTOR2I gridSize = gridHelper.GetGrid() * 10;
644  bool mirroredX = view->IsMirroredX();
645 
646  switch( type )
647  {
649  center -= VECTOR2D( 0, gridSize.y );
650  break;
651 
653  center += VECTOR2D( 0, gridSize.y );
654  break;
655 
657  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
658  break;
659 
661  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
662  break;
663 
664  default:
665  assert( false );
666  break;
667  }
668 
669  view->SetCenter( center );
670 
671  return 0;
672 }
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:133
Class VIEW.
Definition: view.h:58
int PCBNEW_CONTROL::PasteItemsFromClipboard ( const TOOL_EVENT aEvent)

Definition at line 827 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().

828 {
829  CLIPBOARD_IO pi;
830  BOARD tmpBoard;
831  BOARD_ITEM* clipItem = pi.Parse();
832 
833  if( !clipItem )
834  {
835  return 0;
836  }
837 
838  if( clipItem->Type() == PCB_T )
839  static_cast<BOARD*>(clipItem)->ClearAllNetCodes();
840 
841  bool editModules = m_editModules || frame()->IsType( FRAME_PCB_MODULE_EDITOR );
842 
843  // The clipboard can contain two different things, an entire kicad_pcb
844  // or a single module
845 
846  if( editModules && ( !board() || !module() ) )
847  {
848  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
849  return 0;
850  }
851 
852 
853  switch( clipItem->Type() )
854  {
855  case PCB_T:
856  {
857  if( editModules )
858  {
859  wxLogDebug( wxT( "attempting to paste a pcb in the footprint editor\n") );
860  return 0;
861  }
862 
863  placeBoardItems( static_cast<BOARD*>( clipItem ) );
864  break;
865  }
866 
867  case PCB_MODULE_T:
868  {
869  std::vector<BOARD_ITEM *> items;
870 
871  clipItem->SetParent( board() );
872 
873  if( editModules )
874  {
875  auto mod = static_cast<MODULE *>( clipItem );
876 
877  for( auto pad : mod->Pads() )
878  {
879  pad->SetParent ( board()->m_Modules.GetFirst() );
880  items.push_back( pad );
881  }
882  for( auto item : mod->GraphicalItems() )
883  {
884  item->SetParent ( board()->m_Modules.GetFirst() );
885  items.push_back( item );
886  }
887  }
888  else
889  {
890  items.push_back( clipItem );
891  }
892 
893  placeBoardItems( items, true );
894  break;
895  }
896  default:
897  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
898  // FAILED
899  break;
900  }
901  return 1;
902 }
BOARD_ITEM * Parse()
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
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:224
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:135
MODULE * module() const
Definition: pcb_tool.h:137
int placeBoardItems(BOARD *aBoard)
bool m_editModules
Definition: pcb_tool.h:143
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:553
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:136
int PCBNEW_CONTROL::placeBoardItems ( BOARD aBoard)
private

Definition at line 924 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().

925 {
926  std::vector<BOARD_ITEM*> items;
927 
928  for( auto track : aBoard->Tracks() )
929  {
930  if( track->GetFlags() & FLAG0 )
931  track->ClearFlags( FLAG0 );
932  else
933  items.push_back( track );
934  }
935 
936  for( auto module : aBoard->Modules() )
937  {
938  if( module->GetFlags() & FLAG0 )
939  module->ClearFlags( FLAG0 );
940  else
941  items.push_back( module );
942  }
943 
944  for( auto drawing : aBoard->Drawings() )
945  {
946  if( drawing->GetFlags() & FLAG0 )
947  drawing->ClearFlags( FLAG0 );
948  else
949  items.push_back( drawing );
950  }
951 
952  for( auto zone : aBoard->Zones() )
953  {
954  if( zone->GetFlags() & FLAG0 )
955  zone->ClearFlags( FLAG0 );
956  else
957  items.push_back( zone );
958  }
959 
960  // items are new if the current board is not the board source
961  bool isNew = board() != aBoard;
962  return placeBoardItems( items, isNew );
963 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:266
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:250
MODULE * module() const
Definition: pcb_tool.h:137
int placeBoardItems(BOARD *aBoard)
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:127
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:265
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:136
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 966 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.

967 {
969 
970  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
971  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
972 
973  SELECTION& selection = selectionTool->GetSelection();
974 
975  for( auto item : aItems )
976  {
977  item->SetSelected();
978  selection.Add( item );
979 
980  // Add or just select items for the move/place command
981  if( aIsNew )
982  editTool->GetCurrentCommit()->Add( item );
983  else
984  editTool->GetCurrentCommit()->Added( item );
985  }
986 
987  selection.SetReferencePoint( VECTOR2I( 0, 0 ) );
988 
991 
992  return 0;
993 }
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:74
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:219
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 259 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().

260 {
261  m_frame = getEditFrame<PCB_BASE_FRAME>();
262 
263  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
264  {
265  m_gridOrigin->SetPosition( board()->GetGridOrigin() );
266  m_gridOrigin->SetColor( m_frame->GetGridColor() );
267  getView()->Remove( m_gridOrigin.get() );
268  getView()->Add( m_gridOrigin.get() );
269  }
270 }
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:364
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:517
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:334
Rendering engine changes.
Definition: tool_base.h:84
BOARD * board() const
Definition: pcb_tool.h:136
int PCBNEW_CONTROL::ResetCoords ( const TOOL_EVENT aEvent)

Definition at line 752 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().

753 {
754  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
755 
756  m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
758 
759  return 0;
760 }
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 219 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(), highlightNet(), 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().

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

Definition at line 226 of file pcb_tool.cpp.

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

227 {
228  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
229  auto& selection = selTool->GetSelection();
230  return selection;
231 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
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 93 of file pcb_tool.h.

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

Definition at line 706 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().

708 {
709  aFrame->SaveCopyInUndoList( originViewItem, UR_GRIDORIGIN );
710  return DoSetGridOrigin( aView, aFrame, originViewItem, aPoint );
711 }
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 1098 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(), GraphicDisplayMode(), PCB_ACTIONS::graphicDisplayMode, 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, ModuleEdgeOutlines(), PCB_ACTIONS::moduleEdgeOutlines, ModuleTextOutlines(), PCB_ACTIONS::moduleTextOutlines, 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.

1099 {
1100  // Display modes
1113 
1114  // Layer control
1128 
1129  // Cursor control
1140 
1141  // Pan control
1146 
1147  // Grid control
1152 
1153  // Miscellaneous
1160 
1161  // Append control
1163  PCB_ACTIONS::appendBoard.MakeEvent() );
1164 
1166  PCB_ACTIONS::pasteFromClipboard.MakeEvent() );
1167 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:276
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:358
static TOOL_ACTION layerNext
Definition: pcb_actions.h:277
int HighContrastInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:271
static TOOL_ACTION cursorDblClick
Definition: pcb_actions.h:364
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:274
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:275
static TOOL_ACTION showHelp
Definition: pcb_actions.h:391
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:280
static TOOL_ACTION gridResetOrigin
Definition: actions.h:66
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:263
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:279
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:262
int HighContrastMode(const TOOL_EVENT &aEvent)
int ModuleEdgeOutlines(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:353
static TOOL_ACTION pasteFromClipboard
Paste from clipboard.
Definition: pcb_actions.h:320
static TOOL_ACTION switchUnits
Definition: pcb_actions.h:383
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:272
int LayerNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION deleteItemCursor
Definition: pcb_actions.h:384
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:380
static TOOL_ACTION layerTop
Definition: pcb_actions.h:269
static TOOL_ACTION highContrastMode
Definition: pcb_actions.h:264
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:390
static TOOL_ACTION gridFast2
Definition: actions.h:62
static TOOL_ACTION cursorRightFast
Definition: pcb_actions.h:361
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:278
static TOOL_ACTION toBeDone
Definition: pcb_actions.h:393
int GridResetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION panRight
Definition: pcb_actions.h:370
int GraphicDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorClick
Definition: pcb_actions.h:363
int LayerToggle(const TOOL_EVENT &aEvent)
static TOOL_ACTION panUp
Definition: pcb_actions.h:367
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
int GridFast1(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorRight
Definition: pcb_actions.h:356
int ModuleTextOutlines(const TOOL_EVENT &aEvent)
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION moduleEdgeOutlines
Display module edges as outlines.
Definition: pcb_actions.h:326
static TOOL_ACTION panLeft
Definition: pcb_actions.h:369
int ResetCoords(const TOOL_EVENT &aEvent)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:258
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:259
static TOOL_ACTION moduleTextOutlines
Display module texts as outlines.
Definition: pcb_actions.h:329
int ShowHelp(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorLeft
Definition: pcb_actions.h:355
int LayerAlphaDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION highContrastInc
Definition: pcb_actions.h:265
static TOOL_ACTION switchCursor
Definition: pcb_actions.h:382
int ViaDisplayMode(const TOOL_EVENT &aEvent)
int TrackDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION graphicDisplayMode
Definition: pcb_actions.h:260
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:273
int GridFast2(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorDown
Definition: pcb_actions.h:354
static TOOL_ACTION gridSetOrigin
Definition: actions.h:65
static TOOL_ACTION cursorLeftFast
Definition: pcb_actions.h:360
int ToBeDone(const TOOL_EVENT &aEvent)
int LayerSwitch(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:270
static TOOL_ACTION panDown
Definition: pcb_actions.h:368
int PasteItemsFromClipboard(const TOOL_EVENT &aEvent)
static TOOL_ACTION highContrastDec
Definition: pcb_actions.h:266
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:257
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:281
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:261
int HighContrastDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorDownFast
Definition: pcb_actions.h:359
int PCBNEW_CONTROL::ShowHelp ( const TOOL_EVENT aEvent)

Definition at line 1082 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

1083 {
1085 
1086  return 0;
1087 }
EDA_HOTKEY_CONFIG * GetHotkeyConfig() const
Function GetHotkeyConfig() Returns a structure containing currently used hotkey mapping.
Definition: draw_frame.h:397
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 763 of file pcbnew_control.cpp.

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

Referenced by setTransitions().

764 {
765  auto& galOpts = m_frame->GetGalDisplayOptions();
766 
767  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
768  galOpts.NotifyChanged();
769 
770  return 0;
771 }
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:916
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 774 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().

775 {
776  // TODO should not it be refactored to pcb_frame member function?
777  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
778 
779  if( g_UserUnit == INCHES )
780  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
781  else
782  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
783 
784  m_frame->ProcessEvent( evt );
785 
786  return 0;
787 }
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:123
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:57
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 1090 of file pcbnew_control.cpp.

References DisplayInfoMessage(), and m_frame.

Referenced by setTransitions().

1091 {
1092  DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) );
1093 
1094  return 0;
1095 }
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:216
int PCBNEW_CONTROL::TrackDisplayMode ( const TOOL_EVENT aEvent)

Definition at line 277 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().

278 {
279  auto opts = displayOptions();
280 
281  Flip( opts->m_DisplayPcbTrackFill );
282  view()->UpdateDisplayOptions( opts );
283 
284  for( auto track : board()->Tracks() )
285  {
286  if( track->Type() == PCB_TRACE_T )
287  view()->Update( track, KIGFX::GEOMETRY );
288  }
289 
290  canvas()->Refresh();
291 
292  return 0;
293 }
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:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
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:133
void Flip(T &aValue)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:136
void PCBNEW_CONTROL::updateGrid ( )
private

Applies the legacy canvas grid settings for GAL.

Definition at line 1170 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().

1171 {
1172  BASE_SCREEN* screen = m_frame->GetScreen();
1173  //GRID_TYPE grid = screen->GetGrid( idx );
1174  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
1176 }
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:577
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 314 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().

315 {
316  auto opts = displayOptions();
317 
318  Flip( opts->m_DisplayViaFill );
319  view()->UpdateDisplayOptions( opts );
320 
321  for( auto track : board()->Tracks() )
322  {
323  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
324  view()->Update( track, KIGFX::GEOMETRY );
325  }
326 
327  canvas()->Refresh();
328 
329  return 0;
330 }
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:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
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:133
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:136
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 398 of file pcbnew_control.cpp.

References PCB_TOOL::board(), PCB_TOOL::canvas(), PCB_TOOL::displayOptions(), KIGFX::GEOMETRY, BOARD::GetAreaCount(), i, 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().

399 {
400  auto opts = displayOptions();
401 
402  // Apply new display options to the GAL canvas
404  opts->m_DisplayZonesMode = 0;
405  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
406  opts->m_DisplayZonesMode = 1;
407  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
408  opts->m_DisplayZonesMode = 2;
409  else
410  assert( false );
411 
412  view()->UpdateDisplayOptions( opts );
413 
414  for( int i = 0; i < board()->GetAreaCount(); ++i )
415  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
416 
417  canvas()->Refresh();
418 
419  return 0;
420 }
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:263
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:262
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:214
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
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:133
size_t i
Definition: json11.cpp:597
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:136
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:261

Member Data Documentation

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

Grid origin marker.

Definition at line 118 of file pcbnew_control.h.

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

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(), and TOOL_BASE::IsToolActive().

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(), 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: