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
 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_inPlaceSymbol( false ),
66  m_inPlaceImage( false ),
67  m_inSingleClickPlace( false ),
68  m_inTwoClickPlace( false ),
69  m_inDrawSheet( false )
70 {
71 }
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape
bool m_lastTextItalic
Re-entrancy guards.
PINSHEETLABEL_SHAPE m_lastSheetPinType
LABEL_SPIN_STYLE m_lastTextOrientation

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 861 of file sch_drawing_tools.cpp.

862 {
863  SCHEMATIC* schematic = getModel<SCHEMATIC>();
864  SCHEMATIC_SETTINGS& settings = schematic->Settings();
865  SCH_TEXT* textItem = nullptr;
866 
867  switch( aType )
868  {
869  case LAYER_NOTES:
870  textItem = new SCH_TEXT( (wxPoint) aPosition );
871  break;
872 
873  case LAYER_LOCLABEL:
874  textItem = new SCH_LABEL( (wxPoint) aPosition );
875  break;
876 
877  case LAYER_HIERLABEL:
878  textItem = new SCH_HIERLABEL( (wxPoint) aPosition );
879  textItem->SetShape( m_lastGlobalLabelShape );
880  break;
881 
882  case LAYER_GLOBLABEL:
883  textItem = new SCH_GLOBALLABEL( (wxPoint) aPosition );
884  textItem->SetShape( m_lastGlobalLabelShape );
885 
886  if( settings.m_IntersheetRefsShow )
887  static_cast<SCH_GLOBALLABEL*>( textItem )->GetIntersheetRefs()->SetVisible( true );
888 
889  break;
890 
891  default:
892  wxFAIL_MSG( "SCH_EDIT_FRAME::CreateNewText() unknown layer type" );
893  return nullptr;
894  }
895 
896  textItem->SetParent( schematic );
897  textItem->SetBold( m_lastTextBold );
898  textItem->SetItalic( m_lastTextItalic );
900  textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
901  textItem->SetFlags( IS_NEW | IS_MOVING );
902 
903  DIALOG_TEXT_AND_LABEL_PROPERTIES dlg( m_frame, textItem );
904 
905  // Must be quasi modal for syntax help
906  if( dlg.ShowQuasiModal() != wxID_OK || NoPrintableChars( textItem->GetText() ) )
907  {
908  delete textItem;
909  return nullptr;
910  }
911 
912  m_lastTextBold = textItem->IsBold();
913  m_lastTextItalic = textItem->IsItalic();
915 
916  if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIER_LABEL_T )
917  m_lastGlobalLabelShape = textItem->GetShape();
918 
919  return textItem;
920 }
bool IsBold() const
Definition: eda_text.h:183
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:179
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
bool m_lastTextItalic
Re-entrancy guards.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
bool IsItalic() const
Definition: eda_text.h:180
#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:319
void SetBold(bool aBold)
Definition: eda_text.h:182
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:133
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:161
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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 941 of file sch_drawing_tools.cpp.

942 {
943  SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
944  wxString text;
945  SCH_SHEET_PIN* sheetPin;
946 
947  if( aLabel )
948  {
949  text = aLabel->GetText();
950  m_lastSheetPinType = aLabel->GetShape();
951  }
952 
953  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
954  sheetPin->SetFlags( IS_NEW );
955  sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
956  sheetPin->SetShape( m_lastSheetPinType );
957 
958  if( !aLabel )
959  {
960  DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
961 
962  if( dlg.ShowModal() != wxID_OK || NoPrintableChars( sheetPin->GetText() ) )
963  {
964  delete sheetPin;
965  return nullptr;
966  }
967  }
968 
969  m_lastSheetPinType = sheetPin->GetShape();
970 
971  sheetPin->SetPosition( (wxPoint) getViewControls()->GetCursorPosition() );
972 
973  return sheetPin;
974 }
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:97
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
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:133
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 1241 of file sch_drawing_tools.cpp.

1242 {
1243  SCH_SHEET* sheet = nullptr;
1244 
1245  if( m_inDrawSheet )
1246  return 0;
1247 
1248  REENTRANCY_GUARD guard( &m_inDrawSheet );
1249 
1251 
1252  std::string tool = aEvent.GetCommandStr().get();
1253  m_frame->PushTool( tool );
1254 
1255  auto setCursor =
1256  [&]()
1257  {
1259  };
1260 
1261  auto cleanup =
1262  [&] ()
1263  {
1265  m_view->ClearPreview();
1266  delete sheet;
1267  sheet = nullptr;
1268  };
1269 
1270  Activate();
1271  // Must be done after Activate() so that it gets set into the correct context
1272  getViewControls()->ShowCursor( true );
1273  // Set initial cursor
1274  setCursor();
1275 
1276  // Prime the pump
1277  if( aEvent.HasPosition() )
1279 
1280  // Main loop: keep receiving events
1281  while( TOOL_EVENT* evt = Wait() )
1282  {
1283  setCursor();
1284 
1285  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
1286 
1287  if( evt->IsCancelInteractive() )
1288  {
1289  if( sheet )
1290  {
1291  cleanup();
1292  }
1293  else
1294  {
1295  m_frame->PopTool( tool );
1296  break;
1297  }
1298  }
1299  else if( evt->IsActivate() )
1300  {
1301  if( sheet && evt->IsMoveTool() )
1302  {
1303  // we're already drawing our own item; ignore the move tool
1304  evt->SetPassEvent( false );
1305  continue;
1306  }
1307 
1308  if( sheet )
1309  {
1310  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel sheet creation." ) );
1311  evt->SetPassEvent( false );
1312  continue;
1313  }
1314 
1315  if( evt->IsPointEditor() )
1316  {
1317  // don't exit (the point editor runs in the background)
1318  }
1319  else if( evt->IsMoveTool() )
1320  {
1321  // leave ourselves on the stack so we come back after the move
1322  break;
1323  }
1324  else
1325  {
1326  m_frame->PopTool( tool );
1327  break;
1328  }
1329  }
1330  else if( !sheet && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) )
1331  {
1333 
1335 
1336  sheet = new SCH_SHEET( m_frame->GetCurrentSheet().Last(),
1337  static_cast<wxPoint>( cursorPos ) );
1338  sheet->SetFlags( IS_NEW | IS_RESIZING );
1339  sheet->SetScreen( nullptr );
1340  sheet->SetBorderWidth( Mils2iu( cfg->m_Drawing.default_line_thickness ) );
1343  sheet->GetFields()[ SHEETNAME ].SetText( "Untitled Sheet" );
1344  sheet->GetFields()[ SHEETFILENAME ].SetText( "untitled." + KiCadSchematicFileExtension );
1345  sizeSheet( sheet, cursorPos );
1346 
1347  m_view->ClearPreview();
1348  m_view->AddToPreview( sheet->Clone() );
1349  }
1350  else if( sheet && ( evt->IsClick( BUT_LEFT )
1351  || evt->IsDblClick( BUT_LEFT )
1352  || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
1353  {
1354  m_view->ClearPreview();
1355  getViewControls()->SetAutoPan( false );
1356  getViewControls()->CaptureCursor( false );
1357 
1358  // Find the list of paths in the hierarchy that refer to the destination sheet where
1359  // the new sheet will be drawn
1360  SCH_SCREEN* currentScreen = m_frame->GetCurrentSheet().LastScreen();
1361  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1362  SCH_SHEET_LIST instances = hierarchy.FindAllSheetsForScreen( currentScreen );
1363  instances.SortByPageNumbers();
1364 
1365  int pageNum = static_cast<int>( hierarchy.size() ) + 1;
1366 
1367  // Set a page number for all the instances of the new sheet in the hierarchy
1368  for( SCH_SHEET_PATH& instance : instances )
1369  {
1370  SCH_SHEET_PATH sheetPath = instance;
1371  sheetPath.push_back( sheet );
1372  sheet->AddInstance( sheetPath.Path() );
1373  sheet->SetPageNumber( sheetPath, wxString::Format( "%d", pageNum++ ) );
1374  }
1375 
1376  if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
1377  &m_frame->GetCurrentSheet(), nullptr ) )
1378  {
1379  sheet->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1380 
1381  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), sheet, false );
1383  m_selectionTool->AddItemToSel( sheet );
1384  }
1385  else
1386  {
1387  delete sheet;
1388  }
1389 
1390  sheet = nullptr;
1391  }
1392  else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1393  {
1394  sizeSheet( sheet, cursorPos );
1395  m_view->ClearPreview();
1396  m_view->AddToPreview( sheet->Clone() );
1397  }
1398  else if( evt->IsClick( BUT_RIGHT ) )
1399  {
1400  // Warp after context menu only if dragging...
1401  if( !sheet )
1403 
1405  }
1406  else
1407  {
1408  evt->SetPassEvent();
1409  }
1410 
1411  // Enable autopanning and cursor capture only when there is a sheet to be placed
1412  getViewControls()->SetAutoPan( sheet != nullptr );
1413  getViewControls()->CaptureCursor( sheet != nullptr );
1414  }
1415 
1416  getViewControls()->SetAutoPan( false );
1417  getViewControls()->CaptureCursor( false );
1419 
1420  return 0;
1421 }
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:94
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:1562
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
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:156
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:153
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:1129
void SetBorderWidth(int aWidth)
Definition: sch_sheet.h:109
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EESCHEMA_SETTINGS * eeconfig() const
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:88
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 SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:115
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:1540
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:112
#define _(s)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:177
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
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:150
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:458
void Activate()
Run the tool.
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:521
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 KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1087

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, 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(), 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, SCH_SHEET_PATH::Path(), 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 91 of file sch_drawing_tools.cpp.

92 {
93  // calculate the area of the canvas in pixels that create no autopan when
94  // is inside this area the mouse cursor
95  wxSize canvas_size = m_frame->GetCanvas()->GetSize();
96  EDA_RECT canvas_area( wxPoint( 0, 0 ), canvas_size );
97  const KIGFX::VC_SETTINGS& v_settings = getViewControls()->GetSettings();
98 
99  if( v_settings.m_autoPanEnabled )
100  canvas_area.Inflate( - v_settings.m_autoPanMargin );
101 
102  // Gives a margin of 2 pixels
103  canvas_area.Inflate( -2 );
104 
105  return canvas_area;
106 }
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(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_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(), 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::updateParentItem(), 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(), EE_POINT_EDITOR::setEditedPoint(), PL_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(), ROUTER_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(), SCRIPTING_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), COMMON_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(), PAD_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ importHierLabel()

SCH_HIERLABEL * SCH_DRAWING_TOOLS::importHierLabel ( SCH_SHEET aSheet)
private

Definition at line 923 of file sch_drawing_tools.cpp.

924 {
925  if( !aSheet->GetScreen() )
926  return nullptr;
927 
928  for( EDA_ITEM* item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
929  {
930  SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
931 
932  /* A global label has been found: check if there a corresponding sheet label. */
933  if( !aSheet->HasPin( label->GetText() ) )
934  return label;
935  }
936 
937  return nullptr;
938 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:216
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
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:100
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:327
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133

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 74 of file sch_drawing_tools.cpp.

75 {
77 
78  auto belowRootSheetCondition =
79  [&]( const SELECTION& aSel )
80  {
81  return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
82  };
83 
84  CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
85  ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
86 
87  return true;
88 }
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:181
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 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 369 of file sch_drawing_tools.cpp.

370 {
371  SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
372  bool immediateMode = image;
373  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
374 
375  if( m_inPlaceImage )
376  return 0;
377 
379 
381 
382  // Add all the drawable symbols to preview
383  if( image )
384  {
385  image->SetPosition( (wxPoint)cursorPos );
386  m_view->ClearPreview();
387  m_view->AddToPreview( image->Clone() );
388  }
389 
390  std::string tool = aEvent.GetCommandStr().get();
391  m_frame->PushTool( tool );
392  auto setCursor =
393  [&]()
394  {
395  if( image )
397  else
399  };
400 
401  auto cleanup =
402  [&] ()
403  {
405  m_view->ClearPreview();
406  delete image;
407  image = nullptr;
408  };
409 
410  Activate();
411  // Must be done after Activate() so that it gets set into the correct context
412  getViewControls()->ShowCursor( true );
413  // Set initial cursor
414  setCursor();
415 
416  // Prime the pump
417  if( image )
419  else if( !aEvent.IsReactivate() )
421 
422  // Main loop: keep receiving events
423  while( TOOL_EVENT* evt = Wait() )
424  {
425  setCursor();
426  cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
427 
428  if( evt->IsCancelInteractive() )
429  {
430  if( image )
431  {
432  cleanup();
433  }
434  else
435  {
436  m_frame->PopTool( tool );
437  break;
438  }
439 
440  if( immediateMode )
441  {
442  m_frame->PopTool( tool );
443  break;
444  }
445  }
446  else if( evt->IsActivate() )
447  {
448  if( image && evt->IsMoveTool() )
449  {
450  // we're already moving our own item; ignore the move tool
451  evt->SetPassEvent( false );
452  continue;
453  }
454 
455  if( image )
456  {
457  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel image creation." ) );
458  evt->SetPassEvent( false );
459  continue;
460  }
461 
462  if( evt->IsMoveTool() )
463  {
464  // leave ourselves on the stack so we come back after the move
465  break;
466  }
467  else
468  {
469  m_frame->PopTool( tool );
470  break;
471  }
472  }
473  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
474  {
475  if( !image )
476  {
478 
479  // Store the mouse position: if it is outside the canvas,
480  // (happens when clicking on a toolbar tool) one cannot
481  // use the last stored cursor position to place the new symbol
482  // (Current mouse pos after closing the dialog will be used)
484  VECTOR2D initialMousePos = controls->GetMousePosition(false);
485 
486  // Build the rectangle area acceptable to move the cursor without
487  // having an auto-pan
488  EDA_RECT canvas_area = GetCanvasFreeAreaPixels();
489 
490  wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
491  _( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
492  wxFD_OPEN );
493 
494  if( dlg.ShowModal() != wxID_OK )
495  continue;
496 
497  // Restore cursor position after closing the dialog,
498  // but only if it has meaning (i.e inside the canvas)
499  VECTOR2D newMousePos = controls->GetMousePosition( false );
500 
501  if( canvas_area.Contains( wxPoint( initialMousePos ) ) )
502  controls->WarpCursor( controls->GetCursorPosition(), true );
503  else if( !canvas_area.Contains( wxPoint( newMousePos ) ) )
504  // The mouse is outside the canvas area, after closing the dialog,
505  // thus can creating autopan issues. Warp the mouse to the canvas center
506  controls->WarpCursor( canvas_area.Centre(), false );
507 
508  cursorPos = controls->GetMousePosition( true );
509 
510  wxString fullFilename = dlg.GetPath();
511 
512  if( wxFileExists( fullFilename ) )
513  image = new SCH_BITMAP( (wxPoint)cursorPos );
514 
515  if( !image || !image->ReadImageFile( fullFilename ) )
516  {
517  wxMessageBox( _( "Could not load image from '%s'." ), fullFilename );
518  delete image;
519  image = nullptr;
520  continue;
521  }
522 
523  image->SetFlags( IS_NEW | IS_MOVING );
524 
526 
527  m_view->ClearPreview();
528  m_view->AddToPreview( image->Clone() );
529  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
530 
532 
533  getViewControls()->SetCursorPosition( cursorPos, false );
534  setCursor();
535  }
536  else
537  {
539  image = nullptr;
541 
542  m_view->ClearPreview();
543 
544  if( immediateMode )
545  {
546  m_frame->PopTool( tool );
547  break;
548  }
549  }
550  }
551  else if( evt->IsClick( BUT_RIGHT ) )
552  {
553  // Warp after context menu only if dragging...
554  if( !image )
556 
558  }
559  else if( image && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
560  {
561  image->SetPosition( (wxPoint)cursorPos );
562  m_view->ClearPreview();
563  m_view->AddToPreview( image->Clone() );
564  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
565  }
566  else if( image && evt->IsAction( &ACTIONS::doDelete ) )
567  {
568  cleanup();
569  }
570  else
571  {
572  evt->SetPassEvent();
573  }
574 
575  // Enable autopanning and cursor capture only when there is an image to be placed
576  getViewControls()->SetAutoPan( image != nullptr );
577  getViewControls()->CaptureCursor( image != nullptr );
578  }
579 
580  getViewControls()->SetAutoPan( false );
581  getViewControls()->CaptureCursor( false );
583 
584  return 0;
585 }
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:1562
EDA_RECT GetCanvasFreeAreaPixels()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1395
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 (.
#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:1540
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:177
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
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:55
bool IsReactivate() const
Definition: tool_event.h:252
void Activate()
Run the tool.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
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, ACTIONS::doDelete, SCH_BASE_FRAME::GetCanvas(), GetCanvasFreeAreaPixels(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), 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, 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 109 of file sch_drawing_tools.cpp.

110 {
111  SCH_SYMBOL* symbol = aEvent.Parameter<SCH_SYMBOL*>();
113  std::vector<PICKED_SYMBOL>* historyList = nullptr;
114 
115  if( m_inPlaceSymbol )
116  return 0;
117 
119 
120  if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
121  {
122  historyList = &m_symbolHistoryList;
123  }
124  else if (aEvent.IsAction( &EE_ACTIONS::placePower ) )
125  {
126  historyList = &m_powerHistoryList;
127  filter.FilterPowerSymbols( true );
128  }
129  else
130  {
131  wxFAIL_MSG( "PlaceSymbol(): unexpected request" );
132  }
133 
134  std::string tool = aEvent.GetCommandStr().get();
135  m_frame->PushTool( tool );
136 
137  auto addSymbol =
138  [&]( SCH_SYMBOL* aSymbol )
139  {
140  m_frame->SaveCopyForRepeatItem( aSymbol );
141 
143  m_selectionTool->AddItemToSel( aSymbol );
144 
145  aSymbol->SetParent( m_frame->GetScreen() );
146  aSymbol->SetFlags( IS_NEW | IS_MOVING );
147  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), aSymbol, false );
148 
149  // Set IS_MOVING again, as AddItemToScreenAndUndoList() will have cleared it.
150  aSymbol->SetFlags( IS_MOVING );
152  };
153 
154  auto setCursor =
155  [&]()
156  {
159  };
160 
161  auto cleanup =
162  [&] ()
163  {
166  symbol = nullptr;
167  };
168 
169  Activate();
170  // Must be done after Activate() so that it gets set into the correct context
171  getViewControls()->ShowCursor( true );
172  // Set initial cursor
173  setCursor();
174 
175  // Prime the pump
176  if( symbol )
177  {
178  addSymbol( symbol );
179  getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
180  }
181  else if( !aEvent.IsReactivate() )
182  {
184  }
185 
186  // Main loop: keep receiving events
187  while( TOOL_EVENT* evt = Wait() )
188  {
189  setCursor();
190  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
191 
192  if( evt->IsCancelInteractive() )
193  {
194  if( symbol )
195  {
196  cleanup();
197  }
198  else
199  {
200  m_frame->PopTool( tool );
201  break;
202  }
203  }
204  else if( evt->IsActivate() )
205  {
206  if( symbol && evt->IsMoveTool() )
207  {
208  // we're already moving our own item; ignore the move tool
209  evt->SetPassEvent( false );
210  continue;
211  }
212 
213  if( symbol )
214  {
215  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel symbol creation." ) );
216  evt->SetPassEvent( false );
217  continue;
218  }
219 
220  if( evt->IsMoveTool() )
221  {
222  // leave ourselves on the stack so we come back after the move
223  break;
224  }
225  else
226  {
227  m_frame->PopTool( tool );
228  break;
229  }
230  }
231  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
232  {
233  if( !symbol )
234  {
236 
237  // Store the mouse position: if it is outside the canvas,
238  // (happens when clicking on a toolbar tool) one cannot
239  // use the last stored cursor position to place the new symbol
240  // (Current mouse pos after closing the dialog will be used)
242  VECTOR2D initialMousePos = controls->GetMousePosition(false);
243  // Build the rectangle area acceptable to move the cursor without
244  // having an auto-pan
245  EDA_RECT canvas_area = GetCanvasFreeAreaPixels();
246 
247  // Pick the footprint to be placed
248  bool footprintPreviews = m_frame->eeconfig()->m_Appearance.footprint_preview;
249  PICKED_SYMBOL sel = m_frame->PickSymbolFromLibTree( &filter, *historyList, true,
250  1, 1, footprintPreviews );
251  // Restore cursor position after closing the dialog,
252  // but only if it has meaning (i.e inside the canvas)
253  VECTOR2D newMousePos = controls->GetMousePosition(false);
254 
255  if( canvas_area.Contains( wxPoint( initialMousePos ) ) )
256  controls->WarpCursor( controls->GetCursorPosition(), true );
257  else if( !canvas_area.Contains( wxPoint( newMousePos ) ) )
258  // The mouse is outside the canvas area, after closing the dialog,
259  // thus can creating autopan issues. Warp the mouse to the canvas center
260  controls->WarpCursor( canvas_area.Centre(), false );
261 
262  LIB_SYMBOL* libSymbol = sel.LibId.IsValid() ?
263  m_frame->GetLibSymbol( sel.LibId ) : nullptr;
264 
265  if( !libSymbol )
266  continue;
267 
268  wxPoint pos( cursorPos );
269  symbol = new SCH_SYMBOL( *libSymbol, &m_frame->GetCurrentSheet(), sel, pos );
270  addSymbol( symbol );
271 
272  // Update cursor now that we have a symbol
273  setCursor();
274  }
275  else
276  {
278  symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
279 
280  symbol->ClearEditFlags();
281 
284 
285  m_view->Update( symbol );
286  m_frame->GetScreen()->Update( symbol );
287  m_frame->OnModify();
288 
289  SCH_SYMBOL* nextSymbol = nullptr;
290 
293  {
294  int new_unit = symbol->GetUnit();
295 
297  && symbol->GetUnit() < symbol->GetUnitCount() )
298  {
299  new_unit++;
300  }
301  else
302  {
303  new_unit = 1;
304  }
305 
306  // We are either stepping to the next unit or next symbol
307  if( m_frame->eeconfig()->m_SymChooserPanel.keep_symbol || new_unit > 1 )
308  {
309  nextSymbol = static_cast<SCH_SYMBOL*>( symbol->Duplicate() );
310  nextSymbol->SetUnit( new_unit );
311  nextSymbol->SetUnitSelection( new_unit );
312 
313  addSymbol( nextSymbol );
314  }
315  }
316 
317  symbol = nextSymbol;
318  }
319  }
320  else if( evt->IsClick( BUT_RIGHT ) )
321  {
322  // Warp after context menu only if dragging...
323  if( !symbol )
325 
327  }
328  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
329  {
330  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
331  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
332  {
333  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
334 
335  if( symbol )
336  {
337  m_frame->SelectUnit( symbol, unit );
339  }
340  }
341  }
342  else if( symbol && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
343  {
344  symbol->SetPosition( (wxPoint)cursorPos );
345  m_view->Update( symbol );
346  }
347  else if( symbol && evt->IsAction( &ACTIONS::doDelete ) )
348  {
349  cleanup();
350  }
351  else
352  {
353  evt->SetPassEvent();
354  }
355 
356  // Enable autopanning and cursor capture only when there is a symbol to be placed
357  getViewControls()->SetAutoPan( symbol != nullptr );
358  getViewControls()->CaptureCursor( symbol != nullptr );
359  }
360 
361  getViewControls()->SetAutoPan( false );
362  getViewControls()->CaptureCursor( false );
364 
365  return 0;
366 }
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:642
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:331
#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:370
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: getpart.cpp:198
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:547
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 (.
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION placePower
Definition: ee_actions.h:75
#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:78
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: getpart.cpp:88
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:177
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:74
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:72
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:55
bool IsReactivate() const
Definition: tool_event.h:252
void Activate()
Run the tool.
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:264
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:195
void ClearEditFlags()
Definition: eda_item.h:172
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:1518

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, 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(), 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, 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  KICAD_T itemType = aItem->Type();
137  bool selected = aItem->IsSelected();
138 
139  // IS_SELECTED flag should not be set on undo items which were added for
140  // a drag operation.
141  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
142  aItem->ClearSelected();
143 
144  if( m_isSymbolEditor )
145  {
146  SYMBOL_EDIT_FRAME* editFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
147  wxASSERT( editFrame );
148 
149  editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
150  }
151  else
152  {
153  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
154  wxASSERT( editFrame );
155 
156  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
157  {
158  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
159  static_cast<SCH_ITEM*>( aItem->GetParent() ),
160  UNDO_REDO::CHANGED, aAppend );
161  }
162  else
163  {
164  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
165  static_cast<SCH_ITEM*>( aItem ),
166  aType, aAppend );
167  }
168  }
169 
170  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
171  aItem->SetSelected();
172  }
bool IsSelected() const
Definition: eda_item.h:123
void ClearSelected()
Definition: eda_item.h:132
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:156
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:129
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:115
#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:113
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 1437 of file sch_drawing_tools.cpp.

1438 {
1452 }
int TwoClickPlace(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:84
static TOOL_ACTION placeJunction
Definition: ee_actions.h:80
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:81
static TOOL_ACTION importSingleSheetPin
Definition: ee_actions.h:184
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:85
int PlaceSymbol(const TOOL_EVENT &aEvent)
static TOOL_ACTION placePower
Definition: ee_actions.h:75
int SingleClickPlace(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:87
static TOOL_ACTION placeImage
Definition: ee_actions.h:89
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:86
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:74
static TOOL_ACTION placeLabel
Definition: ee_actions.h:82
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:79
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:83
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 588 of file sch_drawing_tools.cpp.

589 {
590  wxPoint cursorPos;
591  KICAD_T type = aEvent.Parameter<KICAD_T>();
594  SCH_ITEM* previewItem;
595  bool loggedInfoBarError = false;
596 
598  return 0;
599 
601 
602  if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
603  {
604  EE_SELECTION& selection = m_selectionTool->GetSelection();
605  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
606 
607  if( wire )
608  {
609  SEG seg( wire->GetStartPoint(), wire->GetEndPoint() );
610  VECTOR2I nearest = seg.NearestPoint( getViewControls()->GetCursorPosition() );
611  getViewControls()->SetCrossHairCursorPosition( nearest, false );
612  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
613  }
614  }
615 
616  switch( type )
617  {
618  case SCH_NO_CONNECT_T:
619  previewItem = new SCH_NO_CONNECT( cursorPos );
620  previewItem->SetParent( m_frame->GetScreen() );
621  break;
622 
623  case SCH_JUNCTION_T:
624  previewItem = new SCH_JUNCTION( cursorPos );
625  previewItem->SetParent( m_frame->GetScreen() );
626  break;
627 
629  previewItem = new SCH_BUS_WIRE_ENTRY( cursorPos );
630  previewItem->SetParent( m_frame->GetScreen() );
631  break;
632 
633  case SCH_SHEET_PIN_T:
634  {
635  EE_SELECTION& selection = m_selectionTool->GetSelection();
636  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() );
637 
638  if( !sheet )
639  return 0;
640 
641  SCH_HIERLABEL* label = importHierLabel( sheet );
642 
643  if( !label )
644  {
645  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
646  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
647  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
648  m_statusPopup->PopupFor( 2000 );
649  return 0;
650  }
651 
652  previewItem = createSheetPin( sheet, label );
653  }
654  break;
655 
656  default:
657  wxASSERT_MSG( false, "Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
658  return 0;
659  }
660 
662 
663  cursorPos = static_cast<wxPoint>( aEvent.HasPosition() ?
664  aEvent.Position() :
665  controls->GetMousePosition() );
666 
667  std::string tool = aEvent.GetCommandStr().get();
668  m_frame->PushTool( tool );
669 
670  auto setCursor =
671  [&]()
672  {
674  };
675 
676  Activate();
677  // Must be done after Activate() so that it gets set into the correct context
678  getViewControls()->ShowCursor( true );
679  // Set initial cursor
680  setCursor();
681 
682  m_view->ClearPreview();
683  m_view->AddToPreview( previewItem->Clone() );
684 
685  // Prime the pump
686  if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T )
688  else
690 
691  // Main loop: keep receiving events
692  while( TOOL_EVENT* evt = Wait() )
693  {
694  setCursor();
695  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
696  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
697 
698  cursorPos = evt->IsPrime() ? (wxPoint) evt->Position()
699  : (wxPoint) controls->GetMousePosition();
700 
701  cursorPos = wxPoint( grid.BestSnapAnchor( cursorPos, LAYER_CONNECTABLE, nullptr ) );
702  controls->ForceCursorPosition( true, cursorPos );
703 
704  if( evt->IsCancelInteractive() )
705  {
706  m_frame->PopTool( tool );
707  break;
708  }
709  else if( evt->IsActivate() )
710  {
711  if( evt->IsMoveTool() )
712  {
713  // leave ourselves on the stack so we come back after the move
714  break;
715  }
716  else
717  {
718  m_frame->PopTool( tool );
719  break;
720  }
721  }
722  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
723  {
724  if( !m_frame->GetScreen()->GetItem( cursorPos, 0, type ) )
725  {
726  if( type == SCH_JUNCTION_T )
727  {
728  if( !m_frame->GetScreen()->IsJunctionNeeded( cursorPos ) )
729  {
730  m_frame->ShowInfoBarError( _( "Junction location contains no joinable "
731  "wires and/or pins." ) );
732  loggedInfoBarError = true;
733  continue;
734  }
735  else if( loggedInfoBarError )
736  {
737  m_frame->GetInfoBar()->Dismiss();
738  }
739  }
740 
741  SCH_ITEM* newItem = static_cast<SCH_ITEM*>( previewItem->Clone() );
742  newItem->SetPosition( cursorPos );
743  newItem->SetFlags( IS_NEW );
744 
745  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), newItem, false );
746 
747  if( type == SCH_JUNCTION_T )
749  else
751 
752  m_frame->OnModify();
753  }
754 
755  if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
756  {
757  m_frame->PopTool( tool );
758  break;
759  }
760  }
761  else if( evt->IsClick( BUT_RIGHT ) )
762  {
764  }
765  else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
766  {
767  previewItem->SetPosition( (wxPoint)cursorPos );
768  m_view->ClearPreview();
769  m_view->AddToPreview( previewItem->Clone() );
770  }
771  else if( evt->Category() == TC_COMMAND )
772  {
773  if( ( type == SCH_BUS_WIRE_ENTRY_T )
774  && ( evt->IsAction( &EE_ACTIONS::rotateCW )
775  || evt->IsAction( &EE_ACTIONS::rotateCCW )
776  || evt->IsAction( &EE_ACTIONS::mirrorV )
777  || evt->IsAction( &EE_ACTIONS::mirrorH ) ) )
778  {
779  SCH_BUS_ENTRY_BASE* busItem = static_cast<SCH_BUS_ENTRY_BASE*>( previewItem );
780 
781  // The bus entries only rotate in one direction
782  if( evt->IsAction( &EE_ACTIONS::rotateCW )
783  || evt->IsAction( &EE_ACTIONS::rotateCCW ) )
784  {
785  busItem->Rotate( busItem->GetPosition() );
786  }
787  else if( evt->IsAction( &EE_ACTIONS::mirrorV ) )
788  {
789  busItem->MirrorVertically( busItem->GetPosition().x );
790  }
791  else if( evt->IsAction( &EE_ACTIONS::mirrorH ) )
792  {
793  busItem->MirrorHorizontally( busItem->GetPosition().y );
794  }
795 
796  m_view->ClearPreview();
797  m_view->AddToPreview( previewItem->Clone() );
798  }
799  else if( evt->IsAction( &EE_ACTIONS::properties ) )
800  {
801  switch( type )
802  {
804  {
805  std::deque<SCH_ITEM*> strokeItems;
806  strokeItems.push_back( previewItem );
807 
808  DIALOG_LINE_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems );
809 
810  if( dlg.ShowModal() == wxID_OK )
811  {
813  m_frame->OnModify();
814  }
815  }
816  break;
817 
818  case SCH_JUNCTION_T:
819  {
820  std::deque<SCH_JUNCTION*> junctions;
821  junctions.push_back( static_cast<SCH_JUNCTION*>( previewItem ) );
822 
823  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
824 
825  if( dlg.ShowModal() == wxID_OK )
826  {
828  m_frame->OnModify();
829  }
830  }
831  break;
832  default:
833  // Do nothing
834  break;
835  }
836 
837  m_view->ClearPreview();
838  m_view->AddToPreview( previewItem->Clone() );
839  }
840  else
841  {
842  evt->SetPassEvent();
843  }
844  }
845  else
846  {
847  evt->SetPassEvent();
848  }
849  }
850 
851  delete previewItem;
852  m_view->ClearPreview();
853 
855  controls->ForceCursorPosition( false );
856 
857  return 0;
858 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
static TOOL_ACTION properties
Definition: ee_actions.h:117
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:253
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1562
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:153
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:116
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:204
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
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:115
static TOOL_ACTION rotateCW
Definition: ee_actions.h:113
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:114
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:1540
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:340
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:177
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:53
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.
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)
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false) const
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:401
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:193
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:144
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::IsJunctionNeeded(), 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 1424 of file sch_drawing_tools.cpp.

1425 {
1426  wxPoint pos = aSheet->GetPosition();
1427  wxPoint size = (wxPoint) aPos - pos;
1428 
1429  size.x = std::max( size.x, MIN_SHEET_WIDTH );
1430  size.y = std::max( size.y, MIN_SHEET_HEIGHT );
1431 
1432  wxPoint grid = m_frame->GetNearestGridPosition( pos + size );
1433  aSheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
1434 }
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:380
#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:809

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 977 of file sch_drawing_tools.cpp.

978 {
979  SCH_ITEM* item = nullptr;
982 
983  if( m_inTwoClickPlace )
984  return 0;
985 
987 
988  bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText );
989  bool isGlobalLabel = aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel );
990  bool isHierLabel = aEvent.IsAction( &EE_ACTIONS::placeHierLabel );
991  bool isNetLabel = aEvent.IsAction( &EE_ACTIONS::placeLabel );
992  bool isSheetPin = aEvent.IsAction( &EE_ACTIONS::importSheetPin );
993  int snapLayer = isText ? LAYER_GRAPHICS : LAYER_CONNECTABLE;
994 
996 
997  std::string tool = aEvent.GetCommandStr().get();
998  m_frame->PushTool( tool );
999  auto setCursor =
1000  [&]()
1001  {
1002  if( item )
1004  else if( isText )
1006  else if( isGlobalLabel )
1008  else if( isNetLabel )
1010  else if( isHierLabel )
1012  else
1014  };
1015 
1016  auto updatePreview =
1017  [&]()
1018  {
1019  m_view->ClearPreview();
1020  m_view->AddToPreview( item->Clone() );
1021  item->RunOnChildren( [&]( SCH_ITEM* aChild )
1022  {
1023  m_view->AddToPreview( aChild->Clone() );
1024  } );
1025  };
1026 
1027  auto cleanup =
1028  [&]()
1029  {
1031  m_view->ClearPreview();
1032  delete item;
1033  item = nullptr;
1034  };
1035 
1036  Activate();
1037  // Must be done after Activate() so that it gets set into the correct context
1038  controls->ShowCursor( true );
1039  // Set initial cursor
1040  setCursor();
1041 
1042  // Prime the pump if the tool isn't being re-activated
1043  if( aEvent.HasPosition() || ( !aEvent.IsReactivate()
1044  && ( isText || isGlobalLabel || isHierLabel || isNetLabel ) ) )
1045  {
1047  }
1048 
1049  // Main loop: keep receiving events
1050  while( TOOL_EVENT* evt = Wait() )
1051  {
1052  setCursor();
1053  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1054  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1055 
1056  VECTOR2I cursorPos = evt->IsPrime() ? evt->Position() : controls->GetMousePosition();
1057  cursorPos = grid.BestSnapAnchor( cursorPos, snapLayer, item );
1058  controls->ForceCursorPosition( true, cursorPos );
1059 
1060  if( evt->IsCancelInteractive() )
1061  {
1062  if( item )
1063  {
1064  cleanup();
1065  }
1066  else
1067  {
1068  m_frame->PopTool( tool );
1069  break;
1070  }
1071  }
1072  else if( evt->IsActivate() )
1073  {
1074  if( item && evt->IsMoveTool() )
1075  {
1076  // we're already moving our own item; ignore the move tool
1077  evt->SetPassEvent( false );
1078  continue;
1079  }
1080 
1081  if( item )
1082  {
1083  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
1084  evt->SetPassEvent( false );
1085  continue;
1086  }
1087 
1088  if( evt->IsPointEditor() )
1089  {
1090  // don't exit (the point editor runs in the background)
1091  }
1092  else if( evt->IsMoveTool() )
1093  {
1094  break;
1095  }
1096  else
1097  {
1098  m_frame->PopTool( tool );
1099  break;
1100  }
1101  }
1102  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1103  {
1104  // First click creates...
1105  if( !item )
1106  {
1108 
1109  if( isText )
1110  {
1111  item = createNewText( cursorPos, LAYER_NOTES );
1112  }
1113  else if( isGlobalLabel )
1114  {
1115  item = createNewText( cursorPos, LAYER_GLOBLABEL );
1116  }
1117  else if( isHierLabel )
1118  {
1119  item = createNewText( cursorPos, LAYER_HIERLABEL );
1120  }
1121  else if( isNetLabel )
1122  {
1123  item = createNewText( cursorPos, LAYER_LOCLABEL );
1124  }
1125  else if( isSheetPin )
1126  {
1127  EDA_ITEM* i;
1128  SCH_HIERLABEL* label = nullptr;
1129  SCH_SHEET* sheet = nullptr;
1130 
1131  if( m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsOnly, &i ) )
1132  sheet = dynamic_cast<SCH_SHEET*>( i );
1133 
1135 
1136  if( !sheet )
1137  {
1138  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1139  m_statusPopup->SetText( _( "Click over a sheet." ) );
1140  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1141  m_statusPopup->PopupFor( 2000 );
1142  item = nullptr;
1143  }
1144  else
1145  {
1146  label = importHierLabel( sheet );
1147 
1148  if( !label )
1149  {
1150  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1151  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
1152  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1153  m_statusPopup->PopupFor( 2000 );
1154  item = nullptr;
1155  }
1156  else
1157  {
1158  item = createSheetPin( sheet, label );
1159  }
1160  }
1161  }
1162 
1163  // Restore cursor after dialog
1164  controls->WarpCursor( controls->GetCursorPosition(), true );
1165 
1166  if( item )
1167  {
1168  item->SetFlags( IS_NEW | IS_MOVING );
1169  item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1170  updatePreview();
1171 
1172  m_selectionTool->AddItemToSel( item );
1173 
1174  // update the cursor so it looks correct before another event
1175  setCursor();
1176  }
1177 
1178  controls->SetCursorPosition( cursorPos, false );
1179  }
1180  else // ... and second click places:
1181  {
1182  item->ClearFlags( IS_MOVING );
1184  false );
1185  item = nullptr;
1186 
1187  m_view->ClearPreview();
1188  }
1189  }
1190  else if( evt->IsClick( BUT_RIGHT ) )
1191  {
1192  // Warp after context menu only if dragging...
1193  if( !item )
1195 
1197  }
1198  else if( item && evt->IsSelectionEvent() )
1199  {
1200  // This happens if our text was replaced out from under us by ConvertTextType()
1201  EE_SELECTION& selection = m_selectionTool->GetSelection();
1202 
1203  if( selection.GetSize() == 1 )
1204  {
1205  item = (SCH_ITEM*) selection.Front();
1206  updatePreview();
1207  }
1208  else
1209  {
1210  item = nullptr;
1211  }
1212  }
1213  else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1214  {
1215  item->SetPosition( (wxPoint) cursorPos );
1216  item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1217  updatePreview();
1218  }
1219  else if( item && evt->IsAction( &ACTIONS::doDelete ) )
1220  {
1221  cleanup();
1222  }
1223  else
1224  {
1225  evt->SetPassEvent();
1226  }
1227 
1228  // Enable autopanning and cursor capture only when there is an item to be placed
1229  controls->SetAutoPan( item != nullptr );
1230  controls->CaptureCursor( item != nullptr );
1231  }
1232 
1233  controls->SetAutoPan( false );
1234  controls->CaptureCursor( false );
1235  controls->ForceCursorPosition( false );
1237  return 0;
1238 }
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:253
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1562
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:79
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:84
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:153
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.
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:449
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
#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:447
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:87
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:1540
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:154
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:177
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:86
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
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:87
static TOOL_ACTION placeLabel
Definition: ee_actions.h:82
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:100
bool IsReactivate() const
Definition: tool_event.h:252
void Activate()
Run the tool.
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:83
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
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.
EDA_ITEM * Front() const
Definition: selection.h:144
static TOOL_ACTION cursorClick
Definition: actions.h:123
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(), ACTIONS::cursorClick, ACTIONS::doDelete, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), SCH_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), 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(), 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(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::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 175 of file ee_tool_base.h.

◆ m_inDrawSheet

bool SCH_DRAWING_TOOLS::m_inDrawSheet
private

Definition at line 97 of file sch_drawing_tools.h.

Referenced by DrawSheet().

◆ m_inPlaceImage

bool SCH_DRAWING_TOOLS::m_inPlaceImage
private

Definition at line 94 of file sch_drawing_tools.h.

Referenced by PlaceImage().

◆ m_inPlaceSymbol

bool SCH_DRAWING_TOOLS::m_inPlaceSymbol
private

Definition at line 93 of file sch_drawing_tools.h.

Referenced by PlaceSymbol().

◆ m_inSingleClickPlace

bool SCH_DRAWING_TOOLS::m_inSingleClickPlace
private

Definition at line 95 of file sch_drawing_tools.h.

Referenced by SingleClickPlace().

◆ m_inTwoClickPlace

bool SCH_DRAWING_TOOLS::m_inTwoClickPlace
private

Definition at line 96 of file sch_drawing_tools.h.

Referenced by TwoClickPlace().

◆ m_isSymbolEditor

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isSymbolEditor
protectedinherited

Definition at line 178 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

Re-entrancy guards.

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(), SCH_MOVE_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PL_SELECTION_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_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 177 of file ee_tool_base.h.

◆ m_statusPopup

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

Definition at line 99 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(), MICROWAVE_TOOL::createInductorBetween(), 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(), PL_SELECTION_TOOL::disambiguateCursor(), EE_SELECTION_TOOL::disambiguateCursor(), PCB_SELECTION_TOOL::disambiguateCursor(), 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(), 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(), SYMBOL_EDITOR_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), 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::isInteractiveDragEnabled(), 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(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_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(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), 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(), 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(), 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 176 of file ee_tool_base.h.


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