KiCad PCB EDA Suite
SCH_DRAWING_TOOLS Class Reference

Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.). More...

#include <sch_drawing_tools.h>

Inheritance diagram for SCH_DRAWING_TOOLS:
EE_TOOL_BASE< SCH_EDIT_FRAME > TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 SCH_DRAWING_TOOLS ()
 
 ~SCH_DRAWING_TOOLS () override
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
int PlaceSymbol (const TOOL_EVENT &aEvent)
 
int SingleClickPlace (const TOOL_EVENT &aEvent)
 
int TwoClickPlace (const TOOL_EVENT &aEvent)
 
int DrawSheet (const TOOL_EVENT &aEvent)
 
int PlaceImage (const TOOL_EVENT &aEvent)
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Protected Member Functions

void updateItem (EDA_ITEM *aItem, bool aUpdateRTree) const
 Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the SCH_SCREEN's RTree. More...
 
void saveCopyInUndoList (EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false)
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

SCH_EDIT_FRAMEm_frame
 
KIGFX::SCH_VIEWm_view
 
EE_SELECTION_TOOLm_selectionTool
 
bool m_isSymbolEditor
 
TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

EDA_RECT GetCanvasFreeAreaPixels ()
 
SCH_TEXTcreateNewText (const VECTOR2I &aPosition, int aType)
 Get the next queued text item. More...
 
SCH_HIERLABELimportHierLabel (SCH_SHEET *aSheet)
 
SCH_SHEET_PINcreateSheetPin (SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
 
void sizeSheet (SCH_SHEET *aSheet, const VECTOR2I &aPos)
 Set up handlers for various events. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 

Private Attributes

std::vector< PICKED_SYMBOLm_symbolHistoryList
 
std::vector< PICKED_SYMBOLm_powerHistoryList
 
PINSHEETLABEL_SHAPE m_lastSheetPinType
 
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape
 
LABEL_SPIN_STYLE m_lastTextOrientation
 
bool m_lastTextBold
 
bool m_lastTextItalic
 
wxString m_mruPath
 Re-entrancy guards. More...
 
bool m_inPlaceSymbol
 
bool m_inPlaceImage
 
bool m_inSingleClickPlace
 
bool m_inTwoClickPlace
 
bool m_inDrawSheet
 
std::unique_ptr< STATUS_TEXT_POPUPm_statusPopup
 

Detailed Description

Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).

Definition at line 44 of file sch_drawing_tools.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

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

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

Constructor & Destructor Documentation

◆ SCH_DRAWING_TOOLS()

SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS ( )

Definition at line 58 of file sch_drawing_tools.cpp.

58  :
59  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
63  m_lastTextBold( false ),
64  m_lastTextItalic( false ),
65  m_mruPath( wxEmptyString ),
66  m_inPlaceSymbol( false ),
67  m_inPlaceImage( false ),
68  m_inSingleClickPlace( false ),
69  m_inTwoClickPlace( false ),
70  m_inDrawSheet( false )
71 {
72 }
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape
PINSHEETLABEL_SHAPE m_lastSheetPinType
LABEL_SPIN_STYLE m_lastTextOrientation
wxString m_mruPath
Re-entrancy guards.

References PS_INPUT, and RIGHT.

◆ ~SCH_DRAWING_TOOLS()

SCH_DRAWING_TOOLS::~SCH_DRAWING_TOOLS ( )
inlineoverride

Definition at line 48 of file sch_drawing_tools.h.

48 { }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

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

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ createNewText()

SCH_TEXT * SCH_DRAWING_TOOLS::createNewText ( const VECTOR2I aPosition,
int  aType 
)
private

Get the next queued text item.

Returns
next SCH_TEXT* or nullptr if empty

Definition at line 869 of file sch_drawing_tools.cpp.

870 {
871  SCHEMATIC* schematic = getModel<SCHEMATIC>();
872  SCHEMATIC_SETTINGS& settings = schematic->Settings();
873  SCH_TEXT* textItem = nullptr;
874 
875  switch( aType )
876  {
877  case LAYER_NOTES:
878  textItem = new SCH_TEXT( (wxPoint) aPosition );
879  break;
880 
881  case LAYER_LOCLABEL:
882  textItem = new SCH_LABEL( (wxPoint) aPosition );
883  break;
884 
885  case LAYER_HIERLABEL:
886  textItem = new SCH_HIERLABEL( (wxPoint) aPosition );
887  textItem->SetShape( m_lastGlobalLabelShape );
888  break;
889 
890  case LAYER_GLOBLABEL:
891  textItem = new SCH_GLOBALLABEL( (wxPoint) aPosition );
892  textItem->SetShape( m_lastGlobalLabelShape );
893 
894  if( settings.m_IntersheetRefsShow )
895  static_cast<SCH_GLOBALLABEL*>( textItem )->GetIntersheetRefs()->SetVisible( true );
896 
897  break;
898 
899  default:
900  wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::CreateNewText() unknown layer type" ) );
901  return nullptr;
902  }
903 
904  textItem->SetParent( schematic );
905  textItem->SetBold( m_lastTextBold );
906  textItem->SetItalic( m_lastTextItalic );
908  textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
909  textItem->SetFlags( IS_NEW | IS_MOVING );
910 
911  DIALOG_TEXT_AND_LABEL_PROPERTIES dlg( m_frame, textItem );
912 
913  // Must be quasi modal for syntax help
914  if( dlg.ShowQuasiModal() != wxID_OK || NoPrintableChars( textItem->GetText() ) )
915  {
916  delete textItem;
917  return nullptr;
918  }
919 
920  m_lastTextBold = textItem->IsBold();
921  m_lastTextItalic = textItem->IsItalic();
923 
924  if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIER_LABEL_T )
925  m_lastGlobalLabelShape = textItem->GetShape();
926 
927  return textItem;
928 }
bool IsBold() const
Definition: eda_text.h:204
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:163
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape
Holds all the data relating to one schematic.
Definition: schematic.h:59
#define IS_NEW
New item, just created.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:167
void SetItalic(bool isItalic)
Definition: eda_text.h:200
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
bool IsItalic() const
Definition: eda_text.h:201
#define IS_MOVING
Item being moved.
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:159
These settings were stored in SCH_BASE_FRAME previously.
LABEL_SPIN_STYLE m_lastTextOrientation
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:330
void SetBold(bool aBold)
Definition: eda_text.h:203
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:161
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SCH_TEXT::GetLabelSpinStyle(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), IS_MOVING, IS_NEW, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, SCHEMATIC_SETTINGS::m_DefaultTextSize, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCHEMATIC_SETTINGS::m_IntersheetRefsShow, m_lastGlobalLabelShape, m_lastTextBold, m_lastTextItalic, m_lastTextOrientation, NoPrintableChars(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EDA_TEXT::SetBold(), EDA_ITEM::SetFlags(), EDA_TEXT::SetItalic(), SCH_TEXT::SetLabelSpinStyle(), EDA_ITEM::SetParent(), SCH_TEXT::SetShape(), EDA_TEXT::SetTextSize(), SCHEMATIC::Settings(), DIALOG_SHIM::ShowQuasiModal(), and EDA_ITEM::Type().

Referenced by TwoClickPlace().

◆ createSheetPin()

SCH_SHEET_PIN * SCH_DRAWING_TOOLS::createSheetPin ( SCH_SHEET aSheet,
SCH_HIERLABEL aLabel 
)
private

Definition at line 949 of file sch_drawing_tools.cpp.

950 {
951  SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
952  wxString text;
953  SCH_SHEET_PIN* sheetPin;
954 
955  if( aLabel )
956  {
957  text = aLabel->GetText();
958  m_lastSheetPinType = aLabel->GetShape();
959  }
960 
961  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
962  sheetPin->SetFlags( IS_NEW );
963  sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
964  sheetPin->SetShape( m_lastSheetPinType );
965 
966  if( !aLabel )
967  {
968  DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
969 
970  if( dlg.ShowModal() != wxID_OK || NoPrintableChars( sheetPin->GetText() ) )
971  {
972  delete sheetPin;
973  return nullptr;
974  }
975  }
976 
977  m_lastSheetPinType = sheetPin->GetShape();
978 
979  sheetPin->SetPosition( (wxPoint) getViewControls()->GetCursorPosition() );
980 
981  return sheetPin;
982 }
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:163
#define IS_NEW
New item, just created.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:167
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
void SetPosition(const wxPoint &aPosition) override
These settings were stored in SCH_BASE_FRAME previously.
PINSHEETLABEL_SHAPE m_lastSheetPinType
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:161

References SCH_TEXT::GetShape(), EDA_TEXT::GetText(), TOOL_BASE::getViewControls(), IS_NEW, SCHEMATIC_SETTINGS::m_DefaultTextSize, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_lastSheetPinType, NoPrintableChars(), SCH_ITEM::Schematic(), EDA_ITEM::SetFlags(), SCH_SHEET_PIN::SetPosition(), SCH_TEXT::SetShape(), EDA_TEXT::SetTextSize(), SCHEMATIC::Settings(), and text.

Referenced by SingleClickPlace(), and TwoClickPlace().

◆ DrawSheet()

int SCH_DRAWING_TOOLS::DrawSheet ( const TOOL_EVENT aEvent)

Definition at line 1265 of file sch_drawing_tools.cpp.

1266 {
1267  SCH_SHEET* sheet = nullptr;
1268 
1269  if( m_inDrawSheet )
1270  return 0;
1271 
1272  REENTRANCY_GUARD guard( &m_inDrawSheet );
1273 
1275 
1276  std::string tool = aEvent.GetCommandStr().get();
1277  m_frame->PushTool( tool );
1278 
1279  auto setCursor =
1280  [&]()
1281  {
1283  };
1284 
1285  auto cleanup =
1286  [&] ()
1287  {
1289  m_view->ClearPreview();
1290  delete sheet;
1291  sheet = nullptr;
1292  };
1293 
1294  Activate();
1295  // Must be done after Activate() so that it gets set into the correct context
1296  getViewControls()->ShowCursor( true );
1297  // Set initial cursor
1298  setCursor();
1299 
1300  // Prime the pump
1301  if( aEvent.HasPosition() )
1303 
1304  // Main loop: keep receiving events
1305  while( TOOL_EVENT* evt = Wait() )
1306  {
1307  setCursor();
1308 
1309  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
1310 
1311  if( evt->IsCancelInteractive() )
1312  {
1313  m_frame->GetInfoBar()->Dismiss();
1314 
1315  if( sheet )
1316  {
1317  cleanup();
1318  }
1319  else
1320  {
1321  m_frame->PopTool( tool );
1322  break;
1323  }
1324  }
1325  else if( evt->IsActivate() )
1326  {
1327  if( sheet && evt->IsMoveTool() )
1328  {
1329  // we're already drawing our own item; ignore the move tool
1330  evt->SetPassEvent( false );
1331  continue;
1332  }
1333 
1334  if( sheet )
1335  {
1336  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel sheet creation." ) );
1337  evt->SetPassEvent( false );
1338  continue;
1339  }
1340 
1341  if( evt->IsPointEditor() )
1342  {
1343  // don't exit (the point editor runs in the background)
1344  }
1345  else if( evt->IsMoveTool() )
1346  {
1347  // leave ourselves on the stack so we come back after the move
1348  break;
1349  }
1350  else
1351  {
1352  m_frame->PopTool( tool );
1353  break;
1354  }
1355  }
1356  else if( !sheet && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) )
1357  {
1359 
1361 
1362  sheet = new SCH_SHEET( m_frame->GetCurrentSheet().Last(),
1363  static_cast<wxPoint>( cursorPos ) );
1364  sheet->SetFlags( IS_NEW | IS_RESIZING );
1365  sheet->SetScreen( nullptr );
1366  sheet->SetBorderWidth( Mils2iu( cfg->m_Drawing.default_line_thickness ) );
1369  sheet->GetFields()[ SHEETNAME ].SetText( wxT( "Untitled Sheet" ) );
1370  sheet->GetFields()[ SHEETFILENAME ].SetText( wxT( "untitled." ) + KiCadSchematicFileExtension );
1371  sizeSheet( sheet, cursorPos );
1372 
1373  m_view->ClearPreview();
1374  m_view->AddToPreview( sheet->Clone() );
1375  }
1376  else if( sheet && ( evt->IsClick( BUT_LEFT )
1377  || evt->IsDblClick( BUT_LEFT )
1378  || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
1379  {
1380  m_view->ClearPreview();
1381  getViewControls()->SetAutoPan( false );
1382  getViewControls()->CaptureCursor( false );
1383 
1384  // Find the list of paths in the hierarchy that refer to the destination sheet where
1385  // the new sheet will be drawn
1386  SCH_SCREEN* currentScreen = m_frame->GetCurrentSheet().LastScreen();
1387  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1388  SCH_SHEET_LIST instances = hierarchy.FindAllSheetsForScreen( currentScreen );
1389  instances.SortByPageNumbers();
1390 
1391  int pageNum = static_cast<int>( hierarchy.size() ) + 1;
1392 
1393  // Set a page number for all the instances of the new sheet in the hierarchy
1394  for( SCH_SHEET_PATH& instance : instances )
1395  {
1396  SCH_SHEET_PATH sheetPath = instance;
1397  sheetPath.push_back( sheet );
1398  sheet->AddInstance( sheetPath );
1399  sheet->SetPageNumber( sheetPath, wxString::Format( wxT( "%d" ), pageNum++ ) );
1400  }
1401 
1402  if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
1403  &m_frame->GetCurrentSheet(), nullptr ) )
1404  {
1405  sheet->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1406 
1407  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), sheet, false );
1409  m_selectionTool->AddItemToSel( sheet );
1410  }
1411  else
1412  {
1413  delete sheet;
1414  }
1415 
1416  sheet = nullptr;
1417  }
1418  else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1419  {
1420  sizeSheet( sheet, cursorPos );
1421  m_view->ClearPreview();
1422  m_view->AddToPreview( sheet->Clone() );
1423  }
1424  else if( evt->IsClick( BUT_RIGHT ) )
1425  {
1426  // Warp after context menu only if dragging...
1427  if( !sheet )
1429 
1431  }
1432  else
1433  {
1434  evt->SetPassEvent();
1435  }
1436 
1437  // Enable autopanning and cursor capture only when there is a sheet to be placed
1438  getViewControls()->SetAutoPan( sheet != nullptr );
1439  getViewControls()->CaptureCursor( sheet != nullptr );
1440  }
1441 
1442  getViewControls()->SetAutoPan( false );
1443  getViewControls()->CaptureCursor( false );
1445 
1446  return 0;
1447 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
static TOOL_ACTION finishSheet
Definition: ee_actions.h:98
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
#define IS_NEW
New item, just created.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
#define IS_RESIZING
Item being resized.
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1614
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:175
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void sizeSheet(SCH_SHEET *aSheet, const VECTOR2I &aPos)
Set up handlers for various events.
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1210
void SetBorderWidth(int aWidth)
Definition: sch_sheet.h:108
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EESCHEMA_SETTINGS * eeconfig() const
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:90
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:114
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void ClearPreview()
Definition: view.cpp:1592
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:111
#define _(s)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:169
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:422
const std::string KiCadSchematicFileExtension
bool EditSheetProperties(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:461
void Activate()
Run the tool.
WX_INFOBAR * GetInfoBar()
SCH_SHEET_PATH & GetCurrentSheet() const
bool HasPosition() const
Definition: tool_event.h:240
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:579
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:123
bool AddInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1165

References _, TOOL_INTERACTIVE::Activate(), SCH_SHEET::AddInstance(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::VIEW::AddToPreview(), ARROW, SCH_SHEET::AutoplaceFields(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::VIEW::ClearPreview(), EE_ACTIONS::clearSelection, SCH_SHEET::Clone(), ACTIONS::cursorClick, EESCHEMA_SETTINGS::DRAWING::default_line_thickness, EESCHEMA_SETTINGS::DRAWING::default_sheet_background_color, EESCHEMA_SETTINGS::DRAWING::default_sheet_border_color, WX_INFOBAR::Dismiss(), SCH_EDIT_FRAME::EditSheetProperties(), SCH_BASE_FRAME::eeconfig(), SCH_SHEET_LIST::FindAllSheetsForScreen(), EE_ACTIONS::finishSheet, Format(), SCH_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), SCH_EDIT_FRAME::GetCurrentSheet(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SCH_SHEET::GetFields(), EDA_BASE_FRAME::GetInfoBar(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), SCHEMATIC::GetSheets(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), IS_NEW, IS_RESIZING, KiCadSchematicFileExtension, SCH_SHEET_PATH::Last(), SCH_SHEET_PATH::LastScreen(), EESCHEMA_SETTINGS::m_Drawing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_inDrawSheet, TOOL_INTERACTIVE::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, PENCIL, TOOLS_HOLDER::PopTool(), SCH_SHEET_PATH::push_back(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::Schematic(), KIGFX::VIEW_CONTROLS::SetAutoPan(), SCH_SHEET::SetBackgroundColor(), SCH_SHEET::SetBorderColor(), SCH_SHEET::SetBorderWidth(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_ITEM::SetFlags(), SCH_SHEET::SetPageNumber(), SCH_SHEET::SetScreen(), SHEETFILENAME, SHEETNAME, TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), EDA_BASE_FRAME::ShowInfoBarMsg(), sizeSheet(), SCH_SHEET_LIST::SortByPageNumbers(), SCH_EDIT_FRAME::UpdateHierarchyNavigator(), TOOL_MANAGER::VetoContextMenuMouseWarp(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ GetCanvasFreeAreaPixels()

EDA_RECT SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels ( )
private
Returns
the "free" area of the canvas in pixels. the free area is the area that create no autopan when the mouse cursor is inside this area

Definition at line 92 of file sch_drawing_tools.cpp.

93 {
94  // calculate the area of the canvas in pixels that create no autopan when
95  // is inside this area the mouse cursor
96  wxSize canvas_size = m_frame->GetCanvas()->GetSize();
97  EDA_RECT canvas_area( wxPoint( 0, 0 ), canvas_size );
98  const KIGFX::VC_SETTINGS& v_settings = getViewControls()->GetSettings();
99 
100  if( v_settings.m_autoPanEnabled )
101  canvas_area.Inflate( - v_settings.m_autoPanMargin );
102 
103  // Gives a margin of 2 pixels
104  canvas_area.Inflate( -2 );
105 
106  return canvas_area;
107 }
const VC_SETTINGS & GetSettings() const
Apply VIEW_CONTROLS settings from an object.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
Definition: view_controls.h:41
float m_autoPanMargin
How fast is panning when in auto mode.
Definition: view_controls.h:76
bool m_autoPanEnabled
Flag for turning on autopanning.
Definition: view_controls.h:70
Handle the component boundary box.
Definition: eda_rect.h:42
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42

References SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetSettings(), TOOL_BASE::getViewControls(), EDA_RECT::Inflate(), KIGFX::VC_SETTINGS::m_autoPanEnabled, KIGFX::VC_SETTINGS::m_autoPanMargin, and EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame.

Referenced by PlaceImage(), and PlaceSymbol().

◆ getEditFrame()

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

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

Definition at line 184 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

109  {
110  return m_type;
111  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206

References TOOL_BASE::m_type.

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

◆ getView()

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

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

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

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), createSheetPin(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), PL_POINT_EDITOR::setEditedPoint(), EE_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149 {
150  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151 
152  goInternal( sptr, aConditions );
153 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), ROUTER_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), PAD_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), DRC_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ importHierLabel()

SCH_HIERLABEL * SCH_DRAWING_TOOLS::importHierLabel ( SCH_SHEET aSheet)
private

Definition at line 931 of file sch_drawing_tools.cpp.

932 {
933  if( !aSheet->GetScreen() )
934  return nullptr;
935 
936  for( EDA_ITEM* item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
937  {
938  SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
939 
940  /* A global label has been found: check if there a corresponding sheet label. */
941  if( !aSheet->HasPin( label->GetText() ) )
942  return label;
943  }
944 
945  return nullptr;
946 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:370
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154

References SCH_SHEET::GetScreen(), EDA_TEXT::GetText(), SCH_SHEET::HasPin(), SCH_SCREEN::Items(), EE_RTREE::OfType(), and SCH_HIER_LABEL_T.

Referenced by SingleClickPlace(), and TwoClickPlace().

◆ Init()

bool SCH_DRAWING_TOOLS::Init ( )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

Definition at line 75 of file sch_drawing_tools.cpp.

76 {
78 
79  auto belowRootSheetCondition =
80  [&]( const SELECTION& aSel )
81  {
82  return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
83  };
84 
85  CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
86  ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
87 
88  return true;
89 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:186
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:66
SCHEMATIC & Schematic() const
SCH_SHEET & Root() const
Definition: schematic.h:92
SCH_SHEET_PATH & GetCurrentSheet() const
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.

References CONDITIONAL_MENU::AddItem(), SCH_EDIT_FRAME::GetCurrentSheet(), TOOL_MENU::GetMenu(), EE_TOOL_BASE< T >::Init(), SCH_SHEET_PATH::Last(), EE_ACTIONS::leaveSheet, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_INTERACTIVE::m_menu, SCHEMATIC::Root(), and SCH_EDIT_FRAME::Schematic().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

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

Referenced by EDIT_TOOL::Drag(), ROUTER_TOOL::handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ PlaceImage()

int SCH_DRAWING_TOOLS::PlaceImage ( const TOOL_EVENT aEvent)

Definition at line 374 of file sch_drawing_tools.cpp.

375 {
376  SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
377  bool immediateMode = image;
378  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
379 
380  if( m_inPlaceImage )
381  return 0;
382 
384 
386 
387  // Add all the drawable symbols to preview
388  if( image )
389  {
390  image->SetPosition( (wxPoint)cursorPos );
391  m_view->ClearPreview();
392  m_view->AddToPreview( image->Clone() );
393  }
394 
395  std::string tool = aEvent.GetCommandStr().get();
396  m_frame->PushTool( tool );
397  auto setCursor =
398  [&]()
399  {
400  if( image )
402  else
404  };
405 
406  auto cleanup =
407  [&] ()
408  {
410  m_view->ClearPreview();
411  delete image;
412  image = nullptr;
413  };
414 
415  Activate();
416  // Must be done after Activate() so that it gets set into the correct context
417  getViewControls()->ShowCursor( true );
418  // Set initial cursor
419  setCursor();
420 
421  // Prime the pump
422  if( image )
424  else if( !aEvent.IsReactivate() )
426 
427  // Main loop: keep receiving events
428  while( TOOL_EVENT* evt = Wait() )
429  {
430  setCursor();
431  cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
432 
433  if( evt->IsCancelInteractive() )
434  {
435  m_frame->GetInfoBar()->Dismiss();
436 
437  if( image )
438  {
439  cleanup();
440  }
441  else
442  {
443  m_frame->PopTool( tool );
444  break;
445  }
446 
447  if( immediateMode )
448  {
449  m_frame->PopTool( tool );
450  break;
451  }
452  }
453  else if( evt->IsActivate() )
454  {
455  if( image && evt->IsMoveTool() )
456  {
457  // we're already moving our own item; ignore the move tool
458  evt->SetPassEvent( false );
459  continue;
460  }
461 
462  if( image )
463  {
464  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel image creation." ) );
465  evt->SetPassEvent( false );
466  continue;
467  }
468 
469  if( evt->IsMoveTool() )
470  {
471  // leave ourselves on the stack so we come back after the move
472  break;
473  }
474  else
475  {
476  m_frame->PopTool( tool );
477  break;
478  }
479  }
480  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
481  {
482  if( !image )
483  {
485 
486  // Store the mouse position: if it is outside the canvas,
487  // (happens when clicking on a toolbar tool) one cannot
488  // use the last stored cursor position to place the new symbol
489  // (Current mouse pos after closing the dialog will be used)
491  VECTOR2D initialMousePos = controls->GetMousePosition(false);
492 
493  // Build the rectangle area acceptable to move the cursor without
494  // having an auto-pan
495  EDA_RECT canvas_area = GetCanvasFreeAreaPixels();
496 
497  wxFileDialog dlg( m_frame, _( "Choose Image" ), m_mruPath, wxEmptyString,
498  _( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
499  wxFD_OPEN );
500 
501  if( dlg.ShowModal() != wxID_OK )
502  continue;
503 
504  // Restore cursor position after closing the dialog,
505  // but only if it has meaning (i.e inside the canvas)
506  VECTOR2D newMousePos = controls->GetMousePosition( false );
507 
508  if( canvas_area.Contains( wxPoint( initialMousePos ) ) )
509  controls->WarpCursor( controls->GetCursorPosition(), true );
510  else if( !canvas_area.Contains( wxPoint( newMousePos ) ) )
511  // The mouse is outside the canvas area, after closing the dialog,
512  // thus can creating autopan issues. Warp the mouse to the canvas center
513  controls->WarpCursor( canvas_area.Centre(), false );
514 
515  cursorPos = controls->GetMousePosition( true );
516 
517  wxString fullFilename = dlg.GetPath();
518  m_mruPath = wxPathOnly( fullFilename );
519 
520  if( wxFileExists( fullFilename ) )
521  image = new SCH_BITMAP( (wxPoint)cursorPos );
522 
523  if( !image || !image->ReadImageFile( fullFilename ) )
524  {
525  wxMessageBox( _( "Could not load image from '%s'." ), fullFilename );
526  delete image;
527  image = nullptr;
528  continue;
529  }
530 
531  image->SetFlags( IS_NEW | IS_MOVING );
532 
534 
535  m_view->ClearPreview();
536  m_view->AddToPreview( image->Clone() );
537  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
538 
540 
541  getViewControls()->SetCursorPosition( cursorPos, false );
542  setCursor();
543  }
544  else
545  {
547  image = nullptr;
549 
550  m_view->ClearPreview();
551 
552  if( immediateMode )
553  {
554  m_frame->PopTool( tool );
555  break;
556  }
557  }
558  }
559  else if( evt->IsClick( BUT_RIGHT ) )
560  {
561  // Warp after context menu only if dragging...
562  if( !image )
564 
566  }
567  else if( image && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
568  {
569  image->SetPosition( (wxPoint)cursorPos );
570  m_view->ClearPreview();
571  m_view->AddToPreview( image->Clone() );
572  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
573  }
574  else if( image && evt->IsAction( &ACTIONS::doDelete ) )
575  {
576  cleanup();
577  }
578  else
579  {
580  evt->SetPassEvent();
581  }
582 
583  // Enable autopanning and cursor capture only when there is an image to be placed
584  getViewControls()->SetAutoPan( image != nullptr );
585  getViewControls()->CaptureCursor( image != nullptr );
586  }
587 
588  getViewControls()->SetAutoPan( false );
589  getViewControls()->CaptureCursor( false );
591 
592  return 0;
593 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
static TOOL_ACTION activatePointEditor
Definition: actions.h:168
#define IS_NEW
New item, just created.
static TOOL_ACTION doDelete
Definition: actions.h:72
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1614
EDA_RECT GetCanvasFreeAreaPixels()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1385
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
EE_SELECTION & GetSelection()
Return the set of currently selected items.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
#define IS_MOVING
Item being moved.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void ClearPreview()
Definition: view.cpp:1592
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:40
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
int AddItemToSel(const TOOL_EVENT &aEvent)
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:422
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint Centre() const
Definition: eda_rect.h:64
bool IsReactivate() const
Definition: tool_event.h:252
void Activate()
Run the tool.
WX_INFOBAR * GetInfoBar()
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
wxString m_mruPath
Re-entrancy guards.
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:123

References _, TOOL_INTERACTIVE::Activate(), ACTIONS::activatePointEditor, SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::VIEW::AddToPreview(), ARROW, BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), EDA_RECT::Centre(), KIGFX::VIEW::ClearPreview(), EE_ACTIONS::clearSelection, EDA_RECT::Contains(), ACTIONS::cursorClick, WX_INFOBAR::Dismiss(), ACTIONS::doDelete, SCH_BASE_FRAME::GetCanvas(), GetCanvasFreeAreaPixels(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EDA_BASE_FRAME::GetInfoBar(), KIGFX::VIEW_CONTROLS::GetMousePosition(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), TOOL_BASE::getViewControls(), image, IS_MOVING, IS_NEW, TOOL_EVENT::IsReactivate(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_inPlaceImage, TOOL_INTERACTIVE::m_menu, m_mruPath, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MOVING, TOOL_EVENT::Parameter(), PENCIL, TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::PushTool(), KIGFX::VIEW::RecacheAllItems(), ACTIONS::refreshPreview, TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), EDA_BASE_FRAME::ShowInfoBarMsg(), TOOL_MANAGER::VetoContextMenuMouseWarp(), TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by setTransitions().

◆ PlaceSymbol()

int SCH_DRAWING_TOOLS::PlaceSymbol ( const TOOL_EVENT aEvent)

Definition at line 110 of file sch_drawing_tools.cpp.

111 {
112  SCH_SYMBOL* symbol = aEvent.Parameter<SCH_SYMBOL*>();
114  std::vector<PICKED_SYMBOL>* historyList = nullptr;
115 
116  if( m_inPlaceSymbol )
117  return 0;
118 
120 
121  if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
122  {
123  historyList = &m_symbolHistoryList;
124  }
125  else if (aEvent.IsAction( &EE_ACTIONS::placePower ) )
126  {
127  historyList = &m_powerHistoryList;
128  filter.FilterPowerSymbols( true );
129  }
130  else
131  {
132  wxFAIL_MSG( wxT( "PlaceSymbol(): unexpected request" ) );
133  }
134 
135  std::string tool = aEvent.GetCommandStr().get();
136  m_frame->PushTool( tool );
137 
138  auto addSymbol =
139  [&]( SCH_SYMBOL* aSymbol )
140  {
141  m_frame->SaveCopyForRepeatItem( aSymbol );
142 
144  m_selectionTool->AddItemToSel( aSymbol );
145 
146  aSymbol->SetParent( m_frame->GetScreen() );
147  aSymbol->SetFlags( IS_NEW | IS_MOVING );
148  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), aSymbol, false );
149 
150  // Set IS_MOVING again, as AddItemToScreenAndUndoList() will have cleared it.
151  aSymbol->SetFlags( IS_MOVING );
153  };
154 
155  auto setCursor =
156  [&]()
157  {
160  };
161 
162  auto cleanup =
163  [&] ()
164  {
167  symbol = nullptr;
168  };
169 
170  Activate();
171  // Must be done after Activate() so that it gets set into the correct context
172  getViewControls()->ShowCursor( true );
173  // Set initial cursor
174  setCursor();
175 
176  // Prime the pump
177  if( symbol )
178  {
179  addSymbol( symbol );
180  getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
181  }
182  else if( !aEvent.IsReactivate() )
183  {
185  }
186 
187  // Main loop: keep receiving events
188  while( TOOL_EVENT* evt = Wait() )
189  {
190  setCursor();
191  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
192 
193  if( evt->IsCancelInteractive() )
194  {
195  m_frame->GetInfoBar()->Dismiss();
196 
197  if( symbol )
198  {
199  cleanup();
200  }
201  else
202  {
203  m_frame->PopTool( tool );
204  break;
205  }
206  }
207  else if( evt->IsActivate() )
208  {
209  if( symbol && evt->IsMoveTool() )
210  {
211  // we're already moving our own item; ignore the move tool
212  evt->SetPassEvent( false );
213  continue;
214  }
215 
216  if( symbol )
217  {
218  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel symbol creation." ) );
219  evt->SetPassEvent( false );
220  continue;
221  }
222 
223  if( evt->IsMoveTool() )
224  {
225  // leave ourselves on the stack so we come back after the move
226  break;
227  }
228  else
229  {
230  m_frame->PopTool( tool );
231  break;
232  }
233  }
234  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
235  {
236  if( !symbol )
237  {
239 
240  // Store the mouse position: if it is outside the canvas,
241  // (happens when clicking on a toolbar tool) one cannot
242  // use the last stored cursor position to place the new symbol
243  // (Current mouse pos after closing the dialog will be used)
245  VECTOR2D initialMousePos = controls->GetMousePosition(false);
246  // Build the rectangle area acceptable to move the cursor without
247  // having an auto-pan
248  EDA_RECT canvas_area = GetCanvasFreeAreaPixels();
249 
250  // Pick the footprint to be placed
251  bool footprintPreviews = m_frame->eeconfig()->m_Appearance.footprint_preview;
252  PICKED_SYMBOL sel = m_frame->PickSymbolFromLibTree( &filter, *historyList, true,
253  1, 1, footprintPreviews );
254  // Restore cursor position after closing the dialog,
255  // but only if it has meaning (i.e inside the canvas)
256  VECTOR2D newMousePos = controls->GetMousePosition(false);
257 
258  if( canvas_area.Contains( wxPoint( initialMousePos ) ) )
259  controls->WarpCursor( controls->GetCursorPosition(), true );
260  else if( !canvas_area.Contains( wxPoint( newMousePos ) ) )
261  // The mouse is outside the canvas area, after closing the dialog,
262  // thus can creating autopan issues. Warp the mouse to the canvas center
263  controls->WarpCursor( canvas_area.Centre(), false );
264 
265  LIB_SYMBOL* libSymbol = sel.LibId.IsValid() ?
266  m_frame->GetLibSymbol( sel.LibId ) : nullptr;
267 
268  if( !libSymbol )
269  continue;
270 
271  wxPoint pos( cursorPos );
272  symbol = new SCH_SYMBOL( *libSymbol, &m_frame->GetCurrentSheet(), sel, pos );
273  addSymbol( symbol );
274 
275  // Update cursor now that we have a symbol
276  setCursor();
277  }
278  else
279  {
281  symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
282 
283  symbol->ClearEditFlags();
284  m_view->Update( symbol );
285  m_frame->GetScreen()->Update( symbol );
286 
291 
292  m_frame->OnModify();
293 
294  SCH_SYMBOL* nextSymbol = nullptr;
295 
298  {
299  int new_unit = symbol->GetUnit();
300 
302  && symbol->GetUnit() < symbol->GetUnitCount() )
303  {
304  new_unit++;
305  }
306  else
307  {
308  new_unit = 1;
309  }
310 
311  // We are either stepping to the next unit or next symbol
312  if( m_frame->eeconfig()->m_SymChooserPanel.keep_symbol || new_unit > 1 )
313  {
314  nextSymbol = static_cast<SCH_SYMBOL*>( symbol->Duplicate() );
315  nextSymbol->SetUnit( new_unit );
316  nextSymbol->SetUnitSelection( new_unit );
317 
318  addSymbol( nextSymbol );
319  }
320  }
321 
322  symbol = nextSymbol;
323  }
324  }
325  else if( evt->IsClick( BUT_RIGHT ) )
326  {
327  // Warp after context menu only if dragging...
328  if( !symbol )
330 
332  }
333  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
334  {
335  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
336  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
337  {
338  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
339 
340  if( symbol )
341  {
342  m_frame->SelectUnit( symbol, unit );
344  }
345  }
346  }
347  else if( symbol && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
348  {
349  symbol->SetPosition( (wxPoint)cursorPos );
350  m_view->Update( symbol );
351  }
352  else if( symbol && evt->IsAction( &ACTIONS::doDelete ) )
353  {
354  cleanup();
355  }
356  else
357  {
358  evt->SetPassEvent();
359  }
360 
361  // Enable autopanning and cursor capture only when there is a symbol to be placed
362  getViewControls()->SetAutoPan( symbol != nullptr );
363  getViewControls()->CaptureCursor( symbol != nullptr );
364  }
365 
366  getViewControls()->SetAutoPan( false );
367  getViewControls()->CaptureCursor( false );
369 
370  return 0;
371 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
void SetPosition(const wxPoint &aPosition) override
Definition: sch_symbol.h:646
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:354
#define IS_NEW
New item, just created.
static TOOL_ACTION doDelete
Definition: actions.h:72
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:393
EDA_RECT GetCanvasFreeAreaPixels()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void SelectUnit(SCH_SYMBOL *aSymbol, int aUnit)
Definition: picksymbol.cpp:211
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
Define a library symbol object.
Definition: lib_symbol.h:96
PANEL_SYM_CHOOSER m_SymChooserPanel
std::vector< PICKED_SYMBOL > m_symbolHistoryList
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:570
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EESCHEMA_SETTINGS * eeconfig() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
static TOOL_ACTION trimOverlappingWires
Definition: ee_actions.h:76
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION placePower
Definition: ee_actions.h:79
#define IS_MOVING
Item being moved.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:85
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
PICKED_SYMBOL PickSymbolFromLibTree(const SCHLIB_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
Definition: picksymbol.cpp:91
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:78
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
std::vector< PICKED_SYMBOL > m_powerHistoryList
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
Schematic symbol object.
Definition: sch_symbol.h:78
int AddItemToSel(const TOOL_EVENT &aEvent)
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:422
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint Centre() const
Definition: eda_rect.h:64
bool IsReactivate() const
Definition: tool_event.h:252
void Activate()
Run the tool.
WX_INFOBAR * GetInfoBar()
SCH_SHEET_PATH & GetCurrentSheet() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:266
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
int GetUnit() const
Definition: sch_symbol.h:196
void ClearEditFlags()
Definition: eda_item.h:171
LIB_ID LibId
Definition: sch_screen.h:82
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:123
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1570

References _, TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), EE_ACTIONS::addNeededJunctions, ARROW, SCH_SYMBOL::AutoplaceFields(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), EDA_RECT::Centre(), EDA_ITEM::ClearEditFlags(), EE_ACTIONS::clearSelection, COMPONENT, EDA_RECT::Contains(), ACTIONS::cursorClick, WX_INFOBAR::Dismiss(), ACTIONS::doDelete, SCH_ITEM::Duplicate(), SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, filter, EESCHEMA_SETTINGS::APPEARANCE::footprint_preview, SCH_BASE_FRAME::GetCanvas(), GetCanvasFreeAreaPixels(), TOOL_EVENT::GetCommandStr(), SCH_EDIT_FRAME::GetCurrentSheet(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EDA_BASE_FRAME::GetInfoBar(), SCH_BASE_FRAME::GetLibSymbol(), KIGFX::VIEW_CONTROLS::GetMousePosition(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitCount(), TOOL_BASE::getViewControls(), ID_POPUP_SCH_SELECT_UNIT_CMP, ID_POPUP_SCH_SELECT_UNIT_SYM_MAX, IS_MOVING, IS_NEW, TOOL_EVENT::IsAction(), TOOL_EVENT::IsReactivate(), LIB_ID::IsValid(), EESCHEMA_SETTINGS::PANEL_SYM_CHOOSER::keep_symbol, PICKED_SYMBOL::LibId, EESCHEMA_SETTINGS::m_Appearance, EESCHEMA_SETTINGS::m_AutoplaceFields, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_inPlaceSymbol, TOOL_INTERACTIVE::m_menu, m_powerHistoryList, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, m_symbolHistoryList, EESCHEMA_SETTINGS::m_SymChooserPanel, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MOVING, SCH_EDIT_FRAME::OnModify(), TOOL_EVENT::Parameter(), SCH_BASE_FRAME::PickSymbolFromLibTree(), EESCHEMA_SETTINGS::PANEL_SYM_CHOOSER::place_all_units, EE_ACTIONS::placePower, EE_ACTIONS::placeSymbol, TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, SCH_EDIT_FRAME::RollbackSchematicFromUndo(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), SCH_EDIT_FRAME::SelectUnit(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), SCH_SYMBOL::SetPosition(), SCH_SYMBOL::SetUnit(), SCH_SYMBOL::SetUnitSelection(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), EDA_BASE_FRAME::ShowInfoBarMsg(), TA_CHOICE_MENU_CHOICE, TC_COMMAND, EE_ACTIONS::trimOverlappingWires, KIGFX::VIEW::Update(), SCH_SCREEN::Update(), TOOL_MANAGER::VetoContextMenuMouseWarp(), TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by setTransitions().

◆ Reset()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::Reset ( RESET_REASON  aReason)
inlineoverridevirtualinherited

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

Implements TOOL_BASE.

Definition at line 86 of file ee_tool_base.h.

87  {
88  if( aReason == MODEL_RELOAD )
89  {
90  // Init variables used by every drawing tool
91  m_frame = getEditFrame<T>();
92  m_isSymbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) != nullptr;
93  }
94 
95  m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
96  }
Model changes (required full reload)
Definition: tool_base.h:80
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36

◆ RunMainStack()

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

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ saveCopyInUndoList()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList ( EDA_ITEM aItem,
UNDO_REDO  aType,
bool  aAppend = false 
)
inlineprotectedinherited

Definition at line 134 of file ee_tool_base.h.

135  {
136  wxASSERT( aItem );
137 
138  KICAD_T itemType = aItem->Type();
139  bool selected = aItem->IsSelected();
140 
141  // IS_SELECTED flag should not be set on undo items which were added for
142  // a drag operation.
143  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
144  aItem->ClearSelected();
145 
146  if( m_isSymbolEditor )
147  {
148  SYMBOL_EDIT_FRAME* editFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
149  wxASSERT( editFrame );
150 
151  editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
152  }
153  else
154  {
155  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
156  wxASSERT( editFrame );
157 
158  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
159  {
160  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
161  static_cast<SCH_ITEM*>( aItem->GetParent() ),
162  UNDO_REDO::CHANGED, aAppend );
163  }
164  else
165  {
166  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
167  static_cast<SCH_ITEM*>( aItem ),
168  aType, aAppend );
169  }
170  }
171 
172  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
173  aItem->SetSelected();
174  }
bool IsSelected() const
Definition: eda_item.h:122
void ClearSelected()
Definition: eda_item.h:131
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:155
Schematic editor (Eeschema) main window.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetSelected()
Definition: eda_item.h:128
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
#define TEMP_SELECTED
flag indicating that the structure has already selected
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
The symbol library editor main window.

◆ SetContextMenu()

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

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

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

◆ setTransitions()

void SCH_DRAWING_TOOLS::setTransitions ( )
overrideprivatevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 1463 of file sch_drawing_tools.cpp.

1464 {
1478 }
int TwoClickPlace(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:88
static TOOL_ACTION placeJunction
Definition: ee_actions.h:84
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:85
static TOOL_ACTION importSingleSheetPin
Definition: ee_actions.h:189
int PlaceImage(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
static TOOL_ACTION drawSheet
Definition: ee_actions.h:89
int PlaceSymbol(const TOOL_EVENT &aEvent)
static TOOL_ACTION placePower
Definition: ee_actions.h:79
int SingleClickPlace(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:91
static TOOL_ACTION placeImage
Definition: ee_actions.h:93
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:90
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:78
static TOOL_ACTION placeLabel
Definition: ee_actions.h:86
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:83
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:87
int DrawSheet(const TOOL_EVENT &aEvent)

References DrawSheet(), EE_ACTIONS::drawSheet, TOOL_INTERACTIVE::Go(), EE_ACTIONS::importSheetPin, EE_ACTIONS::importSingleSheetPin, EE_ACTIONS::placeBusWireEntry, EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, PlaceImage(), EE_ACTIONS::placeImage, EE_ACTIONS::placeJunction, EE_ACTIONS::placeLabel, EE_ACTIONS::placeNoConnect, EE_ACTIONS::placePower, EE_ACTIONS::placeSchematicText, PlaceSymbol(), EE_ACTIONS::placeSymbol, SingleClickPlace(), and TwoClickPlace().

◆ SingleClickPlace()

int SCH_DRAWING_TOOLS::SingleClickPlace ( const TOOL_EVENT aEvent)

Definition at line 596 of file sch_drawing_tools.cpp.

597 {
598  wxPoint cursorPos;
599  KICAD_T type = aEvent.Parameter<KICAD_T>();
602  SCH_ITEM* previewItem;
603  bool loggedInfoBarError = false;
604 
606  return 0;
607 
609 
610  if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
611  {
612  EE_SELECTION& selection = m_selectionTool->GetSelection();
613  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
614 
615  if( wire )
616  {
617  SEG seg( wire->GetStartPoint(), wire->GetEndPoint() );
618  VECTOR2I nearest = seg.NearestPoint( getViewControls()->GetCursorPosition() );
619  getViewControls()->SetCrossHairCursorPosition( nearest, false );
620  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
621  }
622  }
623 
624  switch( type )
625  {
626  case SCH_NO_CONNECT_T:
627  previewItem = new SCH_NO_CONNECT( cursorPos );
628  previewItem->SetParent( m_frame->GetScreen() );
629  break;
630 
631  case SCH_JUNCTION_T:
632  previewItem = new SCH_JUNCTION( cursorPos );
633  previewItem->SetParent( m_frame->GetScreen() );
634  break;
635 
637  previewItem = new SCH_BUS_WIRE_ENTRY( cursorPos );
638  previewItem->SetParent( m_frame->GetScreen() );
639  break;
640 
641  case SCH_SHEET_PIN_T:
642  {
643  EE_SELECTION& selection = m_selectionTool->GetSelection();
644  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() );
645 
646  if( !sheet )
647  return 0;
648 
649  SCH_HIERLABEL* label = importHierLabel( sheet );
650 
651  if( !label )
652  {
653  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
654  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
655  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
656  m_statusPopup->PopupFor( 2000 );
657  return 0;
658  }
659 
660  previewItem = createSheetPin( sheet, label );
661  }
662  break;
663 
664  default:
665  wxASSERT_MSG( false, wxT( "Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" ) );
666  return 0;
667  }
668 
670 
671  cursorPos = static_cast<wxPoint>( aEvent.HasPosition() ?
672  aEvent.Position() :
673  controls->GetMousePosition() );
674 
675  std::string tool = aEvent.GetCommandStr().get();
676  m_frame->PushTool( tool );
677 
678  auto setCursor =
679  [&]()
680  {
682  };
683 
684  Activate();
685  // Must be done after Activate() so that it gets set into the correct context
686  getViewControls()->ShowCursor( true );
687  // Set initial cursor
688  setCursor();
689 
690  m_view->ClearPreview();
691  m_view->AddToPreview( previewItem->Clone() );
692 
693  // Prime the pump
694  if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T )
696  else
698 
699  // Main loop: keep receiving events
700  while( TOOL_EVENT* evt = Wait() )
701  {
702  setCursor();
703  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
704  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
705 
706  cursorPos = evt->IsPrime() ? (wxPoint) evt->Position()
707  : (wxPoint) controls->GetMousePosition();
708 
709  cursorPos = wxPoint( grid.BestSnapAnchor( cursorPos, LAYER_CONNECTABLE, nullptr ) );
710  controls->ForceCursorPosition( true, cursorPos );
711 
712  if( evt->IsCancelInteractive() )
713  {
714  m_frame->PopTool( tool );
715  break;
716  }
717  else if( evt->IsActivate() )
718  {
719  if( evt->IsMoveTool() )
720  {
721  // leave ourselves on the stack so we come back after the move
722  break;
723  }
724  else
725  {
726  m_frame->PopTool( tool );
727  break;
728  }
729  }
730  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
731  {
732  if( !m_frame->GetScreen()->GetItem( cursorPos, 0, type ) )
733  {
734  if( type == SCH_JUNCTION_T )
735  {
736  if( !m_frame->GetScreen()->IsExplicitJunctionAllowed( cursorPos ) )
737  {
738  m_frame->ShowInfoBarError( _( "Junction location contains no joinable "
739  "wires and/or pins." ) );
740  loggedInfoBarError = true;
741  continue;
742  }
743  else if( loggedInfoBarError )
744  {
745  m_frame->GetInfoBar()->Dismiss();
746  }
747  }
748 
749  SCH_ITEM* newItem = static_cast<SCH_ITEM*>( previewItem->Clone() );
750  newItem->SetPosition( cursorPos );
751  newItem->SetFlags( IS_NEW );
752 
753  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), newItem, false );
754 
755  if( type == SCH_JUNCTION_T )
757  else
759 
760  m_frame->OnModify();
761  }
762 
763  if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
764  {
765  m_frame->PopTool( tool );
766  break;
767  }
768  }
769  else if( evt->IsClick( BUT_RIGHT ) )
770  {
772  }
773  else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
774  {
775  previewItem->SetPosition( (wxPoint)cursorPos );
776  m_view->ClearPreview();
777  m_view->AddToPreview( previewItem->Clone() );
778  }
779  else if( evt->Category() == TC_COMMAND )
780  {
781  if( ( type == SCH_BUS_WIRE_ENTRY_T )
782  && ( evt->IsAction( &EE_ACTIONS::rotateCW )
783  || evt->IsAction( &EE_ACTIONS::rotateCCW )
784  || evt->IsAction( &EE_ACTIONS::mirrorV )
785  || evt->IsAction( &EE_ACTIONS::mirrorH ) ) )
786  {
787  SCH_BUS_ENTRY_BASE* busItem = static_cast<SCH_BUS_ENTRY_BASE*>( previewItem );
788 
789  // The bus entries only rotate in one direction
790  if( evt->IsAction( &EE_ACTIONS::rotateCW )
791  || evt->IsAction( &EE_ACTIONS::rotateCCW ) )
792  {
793  busItem->Rotate( busItem->GetPosition() );
794  }
795  else if( evt->IsAction( &EE_ACTIONS::mirrorV ) )
796  {
797  busItem->MirrorVertically( busItem->GetPosition().x );
798  }
799  else if( evt->IsAction( &EE_ACTIONS::mirrorH ) )
800  {
801  busItem->MirrorHorizontally( busItem->GetPosition().y );
802  }
803 
804  m_view->ClearPreview();
805  m_view->AddToPreview( previewItem->Clone() );
806  }
807  else if( evt->IsAction( &EE_ACTIONS::properties ) )
808  {
809  switch( type )
810  {
812  {
813  std::deque<SCH_ITEM*> strokeItems;
814  strokeItems.push_back( previewItem );
815 
816  DIALOG_LINE_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems );
817 
818  if( dlg.ShowModal() == wxID_OK )
819  {
821  m_frame->OnModify();
822  }
823  }
824  break;
825 
826  case SCH_JUNCTION_T:
827  {
828  std::deque<SCH_JUNCTION*> junctions;
829  junctions.push_back( static_cast<SCH_JUNCTION*>( previewItem ) );
830 
831  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
832 
833  if( dlg.ShowModal() == wxID_OK )
834  {
836  m_frame->OnModify();
837  }
838  }
839  break;
840  default:
841  // Do nothing
842  break;
843  }
844 
845  m_view->ClearPreview();
846  m_view->AddToPreview( previewItem->Clone() );
847  }
848  else
849  {
850  evt->SetPassEvent();
851  }
852  }
853  else
854  {
855  evt->SetPassEvent();
856  }
857  }
858 
859  delete previewItem;
860  m_view->ClearPreview();
861 
863  controls->ForceCursorPosition( false );
864 
865  return 0;
866 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
static TOOL_ACTION properties
Definition: ee_actions.h:121
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
SCH_SHEET_PIN * createSheetPin(SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
wxPoint GetStartPoint() const
Definition: sch_line.h:90
#define IS_NEW
New item, just created.
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:252
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1614
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:79
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
static TOOL_ACTION mirrorH
Definition: ee_actions.h:120
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:83
static TOOL_ACTION mirrorV
Definition: ee_actions.h:119
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:42
EE_SELECTION & GetSelection()
Return the set of currently selected items.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual void PopTool(const std::string &actionName)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void ClearPreview()
Definition: view.cpp:1592
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:342
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
Definition: seg.h:40
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
bool IsExplicitJunctionAllowed(const wxPoint &aPosition) const
Indicates that a juction dot may be placed at the given location.
Definition: sch_screen.cpp:433
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
SCH_HIERLABEL * importHierLabel(SCH_SHEET *aSheet)
Class for a wire to bus entry.
void Activate()
Run the tool.
WX_INFOBAR * GetInfoBar()
bool HasPosition() const
Definition: tool_event.h:240
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:263
static TOOL_ACTION refreshPreview
Definition: actions.h:106
EDA_ITEM * Front() const
Definition: selection.h:145
static TOOL_ACTION cursorClick
Definition: actions.h:123
wxPoint GetPosition() const override
wxPoint GetEndPoint() const
Definition: sch_line.h:93
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup

References _, TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), KIGFX::VIEW::AddToPreview(), ARROW, BUT_LEFT, BUT_RIGHT, KIGFX::VIEW::ClearPreview(), EE_ACTIONS::clearSelection, EDA_ITEM::Clone(), createSheetPin(), ACTIONS::cursorClick, WX_INFOBAR::Dismiss(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), SCH_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), SCH_LINE::GetEndPoint(), EDA_BASE_FRAME::GetInfoBar(), SCH_SCREEN::GetItem(), KIGFX::VIEW_CONTROLS::GetMousePosition(), SCH_BUS_ENTRY_BASE::GetPosition(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), SCH_LINE::GetStartPoint(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), grid, TOOL_EVENT::HasPosition(), importHierLabel(), IS_NEW, SCH_SCREEN::IsExplicitJunctionAllowed(), LAYER_CONNECTABLE, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_inSingleClickPlace, TOOL_INTERACTIVE::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, m_statusPopup, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MD_SHIFT, EE_ACTIONS::mirrorH, SCH_BUS_ENTRY_BASE::MirrorHorizontally(), EE_ACTIONS::mirrorV, SCH_BUS_ENTRY_BASE::MirrorVertically(), SCH_EDIT_FRAME::OnModify(), TOOL_EVENT::Parameter(), PLACE, TOOLS_HOLDER::PopTool(), TOOL_EVENT::Position(), TOOL_MANAGER::PostEvent(), EE_ACTIONS::properties, TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, SCH_BUS_ENTRY_BASE::Rotate(), EE_ACTIONS::rotateCCW, EE_ACTIONS::rotateCW, TOOL_MANAGER::RunAction(), SCH_BUS_WIRE_ENTRY_T, SCH_JUNCTION_T, SCH_NO_CONNECT_T, SCH_SHEET_PIN_T, SCH_EDIT_FRAME::SchematicCleanUp(), EVENTS::SelectedItemsModified, KIGFX::VIEW_CONTROLS::SetCrossHairCursorPosition(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_ITEM::SetFlags(), EDA_ITEM::SetParent(), EDA_ITEM::SetPosition(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), EDA_BASE_FRAME::ShowInfoBarError(), TC_COMMAND, SCH_EDIT_FRAME::TestDanglingEnds(), TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by setTransitions().

◆ sizeSheet()

void SCH_DRAWING_TOOLS::sizeSheet ( SCH_SHEET aSheet,
const VECTOR2I aPos 
)
private

Set up handlers for various events.

Definition at line 1450 of file sch_drawing_tools.cpp.

1451 {
1452  wxPoint pos = aSheet->GetPosition();
1453  wxPoint size = (wxPoint) aPos - pos;
1454 
1455  size.x = std::max( size.x, Mils2iu( MIN_SHEET_WIDTH ) );
1456  size.y = std::max( size.y, Mils2iu( MIN_SHEET_HEIGHT ) );
1457 
1458  wxPoint grid = m_frame->GetNearestGridPosition( pos + size );
1459  aSheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
1460 }
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:37
wxPoint GetPosition() const override
Definition: sch_sheet.h:379
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:38
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:887

References EDA_DRAW_FRAME::GetNearestGridPosition(), SCH_SHEET::GetPosition(), grid, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, MIN_SHEET_HEIGHT, MIN_SHEET_WIDTH, SCH_SHEET::Resize(), and VECTOR2< T >::x.

Referenced by DrawSheet().

◆ TwoClickPlace()

int SCH_DRAWING_TOOLS::TwoClickPlace ( const TOOL_EVENT aEvent)

Definition at line 985 of file sch_drawing_tools.cpp.

986 {
987  SCH_ITEM* item = nullptr;
990  bool ignorePrimePosition = false;
991 
992  if( m_inTwoClickPlace )
993  return 0;
994 
996 
997  bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText );
998  bool isGlobalLabel = aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel );
999  bool isHierLabel = aEvent.IsAction( &EE_ACTIONS::placeHierLabel );
1000  bool isNetLabel = aEvent.IsAction( &EE_ACTIONS::placeLabel );
1001  bool isSheetPin = aEvent.IsAction( &EE_ACTIONS::importSheetPin );
1002  int snapLayer = isText ? LAYER_GRAPHICS : LAYER_CONNECTABLE;
1003 
1005 
1006  std::string tool = aEvent.GetCommandStr().get();
1007  m_frame->PushTool( tool );
1008  auto setCursor =
1009  [&]()
1010  {
1011  if( item )
1013  else if( isText )
1015  else if( isGlobalLabel )
1017  else if( isNetLabel )
1019  else if( isHierLabel )
1021  else
1023  };
1024 
1025  auto updatePreview =
1026  [&]()
1027  {
1028  m_view->ClearPreview();
1029  m_view->AddToPreview( item->Clone() );
1030  item->RunOnChildren( [&]( SCH_ITEM* aChild )
1031  {
1032  m_view->AddToPreview( aChild->Clone() );
1033  } );
1034  };
1035 
1036  auto cleanup =
1037  [&]()
1038  {
1040  m_view->ClearPreview();
1041  delete item;
1042  item = nullptr;
1043  };
1044 
1045  Activate();
1046  // Must be done after Activate() so that it gets set into the correct context
1047  controls->ShowCursor( true );
1048  // Set initial cursor
1049  setCursor();
1050 
1051  // Prime the pump if the tool isn't being re-activated
1052  if( aEvent.HasPosition() )
1053  {
1054  m_toolMgr->PrimeTool( aEvent.Position() );
1055  }
1056  else if( !aEvent.IsReactivate() && ( isText
1057  || isGlobalLabel
1058  || isHierLabel
1059  || isNetLabel ) )
1060  {
1061  m_toolMgr->PrimeTool( { 0, 0 } );
1062  ignorePrimePosition = true;
1063  }
1064 
1065  // Main loop: keep receiving events
1066  while( TOOL_EVENT* evt = Wait() )
1067  {
1068  setCursor();
1069  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1070  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1071 
1072  VECTOR2I cursorPos = evt->IsPrime() ? evt->Position() : controls->GetMousePosition();
1073  cursorPos = grid.BestSnapAnchor( cursorPos, snapLayer, item );
1074  controls->ForceCursorPosition( true, cursorPos );
1075 
1076  if( evt->IsCancelInteractive() )
1077  {
1078  m_frame->GetInfoBar()->Dismiss();
1079 
1080  if( item )
1081  {
1082  cleanup();
1083  }
1084  else
1085  {
1086  m_frame->PopTool( tool );
1087  break;
1088  }
1089  }
1090  else if( evt->IsActivate() )
1091  {
1092  if( item && evt->IsMoveTool() )
1093  {
1094  // we're already moving our own item; ignore the move tool
1095  evt->SetPassEvent( false );
1096  continue;
1097  }
1098 
1099  if( item )
1100  {
1101  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
1102  evt->SetPassEvent( false );
1103  continue;
1104  }
1105 
1106  if( evt->IsPointEditor() )
1107  {
1108  // don't exit (the point editor runs in the background)
1109  }
1110  else if( evt->IsMoveTool() )
1111  {
1112  break;
1113  }
1114  else
1115  {
1116  m_frame->PopTool( tool );
1117  break;
1118  }
1119  }
1120  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1121  {
1122  // First click creates...
1123  if( !item )
1124  {
1126 
1127  if( isText )
1128  {
1129  item = createNewText( cursorPos, LAYER_NOTES );
1130  }
1131  else if( isGlobalLabel )
1132  {
1133  item = createNewText( cursorPos, LAYER_GLOBLABEL );
1134  }
1135  else if( isHierLabel )
1136  {
1137  item = createNewText( cursorPos, LAYER_HIERLABEL );
1138  }
1139  else if( isNetLabel )
1140  {
1141  item = createNewText( cursorPos, LAYER_LOCLABEL );
1142  }
1143  else if( isSheetPin )
1144  {
1145  EDA_ITEM* i;
1146  SCH_HIERLABEL* label = nullptr;
1147  SCH_SHEET* sheet = nullptr;
1148 
1149  if( m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsOnly, &i ) )
1150  sheet = dynamic_cast<SCH_SHEET*>( i );
1151 
1153 
1154  if( !sheet )
1155  {
1156  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1157  m_statusPopup->SetText( _( "Click over a sheet." ) );
1158  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1159  m_statusPopup->PopupFor( 2000 );
1160  item = nullptr;
1161  }
1162  else
1163  {
1164  label = importHierLabel( sheet );
1165 
1166  if( !label )
1167  {
1168  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1169  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
1170  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1171  m_statusPopup->PopupFor( 2000 );
1172  item = nullptr;
1173  }
1174  else
1175  {
1176  item = createSheetPin( sheet, label );
1177  }
1178  }
1179  }
1180 
1181  // If we started with a click on a tool button or menu then continue with the
1182  // current mouse position. Otherwise warp back to the original click position.
1183  if( evt->IsPrime() && ignorePrimePosition )
1184  cursorPos = grid.Align( controls->GetMousePosition() );
1185  else
1186  controls->WarpCursor( cursorPos, true );
1187 
1188  if( item )
1189  {
1190  item->SetPosition( (wxPoint) cursorPos );
1191 
1192  item->SetFlags( IS_NEW | IS_MOVING );
1193  item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1194  updatePreview();
1195 
1196  m_selectionTool->AddItemToSel( item );
1197 
1198  // update the cursor so it looks correct before another event
1199  setCursor();
1200  }
1201 
1202  controls->SetCursorPosition( cursorPos, false );
1203  }
1204  else // ... and second click places:
1205  {
1206  item->ClearFlags( IS_MOVING );
1208  false );
1209  item = nullptr;
1210 
1211  m_view->ClearPreview();
1212  }
1213  }
1214  else if( evt->IsClick( BUT_RIGHT ) )
1215  {
1216  // Warp after context menu only if dragging...
1217  if( !item )
1219 
1221  }
1222  else if( item && evt->IsSelectionEvent() )
1223  {
1224  // This happens if our text was replaced out from under us by ConvertTextType()
1225  EE_SELECTION& selection = m_selectionTool->GetSelection();
1226 
1227  if( selection.GetSize() == 1 )
1228  {
1229  item = (SCH_ITEM*) selection.Front();
1230  updatePreview();
1231  }
1232  else
1233  {
1234  item = nullptr;
1235  }
1236  }
1237  else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1238  {
1239  item->SetPosition( (wxPoint) cursorPos );
1240  item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1241  updatePreview();
1242  }
1243  else if( item && evt->IsAction( &ACTIONS::doDelete ) )
1244  {
1245  cleanup();
1246  }
1247  else
1248  {
1249  evt->SetPassEvent();
1250  }
1251 
1252  // Enable autopanning and cursor capture only when there is an item to be placed
1253  controls->SetAutoPan( item != nullptr );
1254  controls->CaptureCursor( item != nullptr );
1255  }
1256 
1257  controls->SetAutoPan( false );
1258  controls->CaptureCursor( false );
1259  controls->ForceCursorPosition( false );
1261  return 0;
1262 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
SCH_SHEET_PIN * createSheetPin(SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
#define IS_NEW
New item, just created.
static TOOL_ACTION doDelete
Definition: actions.h:72
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:252
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1614
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:79
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:88
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:46
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:83
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
EE_SELECTION & GetSelection()
Return the set of currently selected items.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
#define IS_MOVING
Item being moved.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:442
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:91
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void ClearPreview()
Definition: view.cpp:1592
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:90
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
static TOOL_ACTION placeLabel
Definition: ee_actions.h:86
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
int AddItemToSel(const TOOL_EVENT &aEvent)
bool SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before c...
SCH_HIERLABEL * importHierLabel(SCH_SHEET *aSheet)
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:422
SCH_TEXT * createNewText(const VECTOR2I &aPosition, int aType)
Get the next queued text item.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
bool IsReactivate() const
Definition: tool_event.h:252
void Activate()
Run the tool.
WX_INFOBAR * GetInfoBar()
bool HasPosition() const
Definition: tool_event.h:240
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:87
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:263
static TOOL_ACTION refreshPreview
Definition: actions.h:106
EDA_ITEM * Front() const
Definition: selection.h:145
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup

References _, TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::VIEW::AddToPreview(), ARROW, SCH_ITEM::AutoplaceFields(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), EDA_ITEM::ClearFlags(), KIGFX::VIEW::ClearPreview(), EE_ACTIONS::clearSelection, EE_SELECTION_TOOL::ClearSelection(), EDA_ITEM::Clone(), createNewText(), createSheetPin(), WX_INFOBAR::Dismiss(), ACTIONS::doDelete, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), SCH_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), EDA_BASE_FRAME::GetInfoBar(), KIGFX::VIEW_CONTROLS::GetMousePosition(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), SELECTION::GetSize(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), grid, TOOL_EVENT::HasPosition(), importHierLabel(), EE_ACTIONS::importSheetPin, IS_MOVING, IS_NEW, TOOL_EVENT::IsAction(), TOOL_EVENT::IsReactivate(), LABEL_GLOBAL, LABEL_HIER, LABEL_NET, LAYER_CONNECTABLE, LAYER_GLOBLABEL, LAYER_GRAPHICS, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_inTwoClickPlace, TOOL_INTERACTIVE::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, m_statusPopup, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MD_SHIFT, PENCIL, PLACE, EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, EE_ACTIONS::placeLabel, EE_ACTIONS::placeSchematicText, TOOLS_HOLDER::PopTool(), TOOL_EVENT::Position(), TOOL_MANAGER::PrimeTool(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, TOOL_MANAGER::RunAction(), SCH_ITEM::RunOnChildren(), EE_SELECTION_TOOL::SelectPoint(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), EDA_ITEM::SetFlags(), EDA_ITEM::SetPosition(), EE_COLLECTOR::SheetsOnly, TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), EDA_BASE_FRAME::ShowInfoBarMsg(), TEXT, TOOL_MANAGER::VetoContextMenuMouseWarp(), TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by setTransitions().

◆ updateItem()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem ( EDA_ITEM aItem,
bool  aUpdateRTree 
) const
inlineprotectedinherited

Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the SCH_SCREEN's RTree.

Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.

Definition at line 103 of file ee_tool_base.h.

◆ Wait()

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

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), PL_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_frame

SCH_EDIT_FRAME * EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame
protectedinherited

Definition at line 177 of file ee_tool_base.h.

◆ m_inDrawSheet

bool SCH_DRAWING_TOOLS::m_inDrawSheet
private

Definition at line 98 of file sch_drawing_tools.h.

Referenced by DrawSheet().

◆ m_inPlaceImage

bool SCH_DRAWING_TOOLS::m_inPlaceImage
private

Definition at line 95 of file sch_drawing_tools.h.

Referenced by PlaceImage().

◆ m_inPlaceSymbol

bool SCH_DRAWING_TOOLS::m_inPlaceSymbol
private

Definition at line 94 of file sch_drawing_tools.h.

Referenced by PlaceSymbol().

◆ m_inSingleClickPlace

bool SCH_DRAWING_TOOLS::m_inSingleClickPlace
private

Definition at line 96 of file sch_drawing_tools.h.

Referenced by SingleClickPlace().

◆ m_inTwoClickPlace

bool SCH_DRAWING_TOOLS::m_inTwoClickPlace
private

Definition at line 97 of file sch_drawing_tools.h.

Referenced by TwoClickPlace().

◆ m_isSymbolEditor

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isSymbolEditor
protectedinherited

Definition at line 180 of file ee_tool_base.h.

◆ m_lastGlobalLabelShape

PINSHEETLABEL_SHAPE SCH_DRAWING_TOOLS::m_lastGlobalLabelShape
private

Definition at line 87 of file sch_drawing_tools.h.

Referenced by createNewText().

◆ m_lastSheetPinType

PINSHEETLABEL_SHAPE SCH_DRAWING_TOOLS::m_lastSheetPinType
private

Definition at line 86 of file sch_drawing_tools.h.

Referenced by createSheetPin().

◆ m_lastTextBold

bool SCH_DRAWING_TOOLS::m_lastTextBold
private

Definition at line 89 of file sch_drawing_tools.h.

Referenced by createNewText().

◆ m_lastTextItalic

bool SCH_DRAWING_TOOLS::m_lastTextItalic
private

Definition at line 90 of file sch_drawing_tools.h.

Referenced by createNewText().

◆ m_lastTextOrientation

LABEL_SPIN_STYLE SCH_DRAWING_TOOLS::m_lastTextOrientation
private

Definition at line 88 of file sch_drawing_tools.h.

Referenced by createNewText().

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

The functions below are not yet implemented - their interface may change.

Definition at line 125 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), ROUTER_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), PL_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_CONTROL::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PL_SELECTION_TOOL::Init(), Init(), BOARD_EDITOR_CONTROL::Init(), GERBVIEW_SELECTION_TOOL::Init(), EDA_3D_CONTROLLER::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), PCB_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PICKER_TOOL::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_PICKER_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PL_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and TwoClickPlace().

◆ m_mruPath

wxString SCH_DRAWING_TOOLS::m_mruPath
private

Re-entrancy guards.

Definition at line 91 of file sch_drawing_tools.h.

Referenced by PlaceImage().

◆ m_powerHistoryList

std::vector<PICKED_SYMBOL> SCH_DRAWING_TOOLS::m_powerHistoryList
private

Definition at line 84 of file sch_drawing_tools.h.

Referenced by PlaceSymbol().

◆ m_selectionTool

EE_SELECTION_TOOL* EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool
protectedinherited

Definition at line 179 of file ee_tool_base.h.

◆ m_statusPopup

std::unique_ptr<STATUS_TEXT_POPUP> SCH_DRAWING_TOOLS::m_statusPopup
private

Definition at line 100 of file sch_drawing_tools.h.

Referenced by SingleClickPlace(), and TwoClickPlace().

◆ m_symbolHistoryList

std::vector<PICKED_SYMBOL> SCH_DRAWING_TOOLS::m_symbolHistoryList
private

Definition at line 83 of file sch_drawing_tools.h.

Referenced by PlaceSymbol().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

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

Definition at line 209 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), PCB_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), BOARD_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), PL_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PL_EDIT_TOOL::Copy(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), DRC_TOOL::CrossProbe(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::Drag(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_REANNOTATE_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), CONVERT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), GLOBAL_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), PL_POINT_EDITOR::Init(), BOARD_INSPECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_POINT_EDITOR::Init(), BOARD_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), PL_SELECTION_TOOL::onDisambiguationExpire(), EE_SELECTION_TOOL::onDisambiguationExpire(), PCB_SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::Print(), GERBVIEW_CONTROL::Print(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), PCB_SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), PCB_SELECTION_TOOL::RequestSelection(), PAD_TOOL::Reset(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), PCB_SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_SELECTION_TOOL::selectSameSheet(), PCB_SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), TwoClickPlace(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PCB_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), EE_POINT_EDITOR::updateParentItem(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), and BOARD_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 213 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 206 of file tool_base.h.

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

◆ m_view

KIGFX::SCH_VIEW* EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view
protectedinherited

Definition at line 178 of file ee_tool_base.h.


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