KiCad PCB EDA Suite
SCH_EDIT_TOOL Class Reference

#include <sch_edit_tool.h>

Inheritance diagram for SCH_EDIT_TOOL:
EE_TOOL_BASE< SCH_EDIT_FRAME > TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 SCH_EDIT_TOOL ()
 
 ~SCH_EDIT_TOOL () override
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int Rotate (const TOOL_EVENT &aEvent)
 
int Mirror (const TOOL_EVENT &aEvent)
 
int Duplicate (const TOOL_EVENT &aEvent)
 
int RepeatDrawItem (const TOOL_EVENT &aEvent)
 
int Properties (const TOOL_EVENT &aEvent)
 
int EditField (const TOOL_EVENT &aEvent)
 
int AutoplaceFields (const TOOL_EVENT &aEvent)
 
int UpdateFields (const TOOL_EVENT &aEvent)
 
int ConvertDeMorgan (const TOOL_EVENT &aEvent)
 
int ChangeShape (const TOOL_EVENT &aEvent)
 
int ChangeTextType (const TOOL_EVENT &aEvent)
 Change a text type to another one. More...
 
int BreakWire (const TOOL_EVENT &aEvent)
 
int CleanupSheetPins (const TOOL_EVENT &aEvent)
 
int GlobalEdit (const TOOL_EVENT &aEvent)
 
int DoDelete (const TOOL_EVENT &aEvent)
 

Deletes the selected items, or the item under the cursor.

More...
 
int DeleteItemCursor (const TOOL_EVENT &aEvent)
 

Runs the deletion tool.

More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
void Activate ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Protected Member Functions

void updateView (EDA_ITEM *aItem) const
 

Similar to getView()->Update(), but handles items that are redrawn by their parents.

More...
 
void saveCopyInUndoList (EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
 

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

More...
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

SCH_EDIT_FRAMEm_frame
 
KIGFX::SCH_VIEWm_view
 
EE_SELECTION_TOOLm_selectionTool
 
bool m_isLibEdit
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

void editFieldText (SCH_FIELD *aField)
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 

Private Attributes

EDA_ITEMm_pickerItem
 

Detailed Description

Definition at line 36 of file sch_edit_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ SCH_EDIT_TOOL()

SCH_EDIT_TOOL::SCH_EDIT_TOOL ( )

Definition at line 121 of file sch_edit_tool.cpp.

121  :
122  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
123 {
124  m_pickerItem = nullptr;
125 }
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:89

References m_pickerItem.

◆ ~SCH_EDIT_TOOL()

SCH_EDIT_TOOL::~SCH_EDIT_TOOL ( )
inlineoverride

Definition at line 40 of file sch_edit_tool.h.

40 { }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::Move(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

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

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ AutoplaceFields()

int SCH_EDIT_TOOL::AutoplaceFields ( const TOOL_EVENT aEvent)

Definition at line 1172 of file sch_edit_tool.cpp.

1173 {
1175 
1176  if( selection.Empty() )
1177  return 0;
1178 
1179  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1180 
1181  if( !component->IsNew() )
1182  m_frame->SaveCopyInUndoList( component, UR_CHANGED );
1183 
1184  component->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1185 
1186  m_frame->GetScreen()->Update( component );
1187  updateView( component );
1188  m_frame->OnModify();
1189 
1190  if( selection.IsHover() )
1192 
1193  return 0;
1194 }
bool IsHover() const
Definition: selection.h:71
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
bool IsNew() const
Definition: base_struct.h:203
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the component.
Schematic symbol object.
Definition: sch_component.h:88
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)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:302
EDA_ITEM * Front() const
Definition: selection.h:184

References SCH_COMPONENT::AutoplaceFields(), EE_ACTIONS::clearSelection, EE_COLLECTOR::ComponentsOnly, SELECTION::Empty(), SELECTION::Front(), SCH_EDIT_FRAME::GetScreen(), SELECTION::IsHover(), EDA_ITEM::IsNew(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SCREEN::Update(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView(), and UR_CHANGED.

Referenced by setTransitions().

◆ BreakWire()

int SCH_EDIT_TOOL::BreakWire ( const TOOL_EVENT aEvent)

Definition at line 1559 of file sch_edit_tool.cpp.

1560 {
1561  auto cursorPos = wxPoint( getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ) );
1562 
1563  if( m_frame->BreakSegments( cursorPos ) )
1564  {
1565  if( m_frame->GetScreen()->IsJunctionNeeded( cursorPos, true ) )
1566  m_frame->AddJunction( cursorPos, true, false );
1567 
1569 
1570  m_frame->OnModify();
1571  m_frame->GetCanvas()->Refresh();
1572  }
1573 
1574  return 0;
1575 }
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:436
bool BreakSegments(const wxPoint &aPoint, SCH_SCREEN *aScreen=nullptr)
Checks every wire and bus for a intersection at aPoint and break into two segments at aPoint if an in...
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
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
Function getViewControls()
Definition: tool_base.cpp:42

References SCH_EDIT_FRAME::AddJunction(), SCH_EDIT_FRAME::BreakSegments(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetScreen(), TOOL_BASE::getViewControls(), SCH_SCREEN::IsJunctionNeeded(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, MD_ALT, TOOL_EVENT::Modifier(), SCH_EDIT_FRAME::OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), and SCH_EDIT_FRAME::TestDanglingEnds().

Referenced by setTransitions().

◆ ChangeShape()

int SCH_EDIT_TOOL::ChangeShape ( const TOOL_EVENT aEvent)

Definition at line 1431 of file sch_edit_tool.cpp.

1432 {
1433  EE_SELECTION& selection = m_selectionTool->GetSelection();
1434  char shape = aEvent.Parameter<char>();
1435 
1436  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1437  {
1438  SCH_BUS_ENTRY_BASE* entry = dynamic_cast<SCH_BUS_ENTRY_BASE*>( selection.GetItem( i ) );
1439 
1440  if( entry )
1441  {
1442  if( entry->GetEditFlags() == 0 )
1444 
1445  entry->SetBusEntryShape( shape );
1447 
1448  m_frame->GetScreen()->Update( entry );
1449  updateView( entry );
1450  m_frame->OnModify( );
1451  }
1452  }
1453 
1455  drawingTool->SetLastBusEntryShape( shape );
1456 
1457  return 0;
1458 }
SCH_DRAWING_TOOLS.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void SetLastBusEntryShape(char aShape)
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
EE_SELECTION & GetSelection()
Function GetSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:244
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
void SetBusEntryShape(char aShape)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
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)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:302

References EDA_ITEM::GetEditFlags(), SELECTION::GetItem(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), SELECTION::GetSize(), TOOL_MANAGER::GetTool(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), TOOL_EVENT::Parameter(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_BUS_ENTRY_BASE::SetBusEntryShape(), SCH_DRAWING_TOOLS::SetLastBusEntryShape(), SCH_EDIT_FRAME::TestDanglingEnds(), SCH_SCREEN::Update(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView(), and UR_CHANGED.

Referenced by setTransitions().

◆ ChangeTextType()

int SCH_EDIT_TOOL::ChangeTextType ( const TOOL_EVENT aEvent)

Change a text type to another one.

The new text, label, hierarchical label, or global label is created from the old text and the old text object is deleted.

A tricky case is when the 'old" text is being edited (i.e. moving) because we must create a new text, and prepare the undo/redo command data for this change and the current move/edit command

Definition at line 1461 of file sch_edit_tool.cpp.

1462 {
1463  KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
1465  EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
1466 
1467  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1468  {
1469  SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
1470 
1471  if( text && text->Type() != convertTo )
1472  {
1473  bool selected = text->IsSelected();
1474  SCH_TEXT* newtext = nullptr;
1475  const wxPoint& position = text->GetPosition();
1476  LABEL_SPIN_STYLE orientation = text->GetLabelSpinStyle();
1477  wxString txt = UnescapeString( text->GetText() );
1478 
1479  // There can be characters in a SCH_TEXT object that can break labels so we have to
1480  // fix them here.
1481  if( text->Type() == SCH_TEXT_T )
1482  {
1483  txt.Replace( "\n", "_" );
1484  txt.Replace( "\r", "_" );
1485  txt.Replace( "\t", "_" );
1486  txt.Replace( " ", "_" );
1487  }
1488 
1489  // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
1490  if( convertTo != SCH_TEXT_T )
1491  txt = EscapeString( txt, CTX_NETNAME );
1492 
1493  switch( convertTo )
1494  {
1495  case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
1496  case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
1497  case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break;
1498  case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
1499 
1500  default:
1501  wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", convertTo ) );
1502  return 0;
1503  }
1504 
1505  // Copy the old text item settings to the new one. Justifications are not copied
1506  // because they are not used in labels. Justifications will be set to default value
1507  // in the new text item type.
1508  //
1509  newtext->SetFlags( text->GetEditFlags() );
1510  newtext->SetShape( text->GetShape() );
1511  newtext->SetLabelSpinStyle( orientation );
1512  newtext->SetTextSize( text->GetTextSize() );
1513  newtext->SetTextThickness( text->GetTextThickness() );
1514  newtext->SetItalic( text->IsItalic() );
1515  newtext->SetBold( text->IsBold() );
1516  newtext->SetIsDangling( text->IsDangling() );
1517 
1518  if( selected )
1520 
1521  if( !text->IsNew() )
1522  {
1524  m_frame->SaveCopyInUndoList( newtext, UR_NEW, true );
1525 
1526  m_frame->RemoveFromScreen( text );
1527  m_frame->AddToScreen( newtext );
1528  }
1529 
1530  if( selected )
1531  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
1532 
1533  // Otherwise, pointer is owned by the undo stack
1534  if( text->IsNew() )
1535  delete text;
1536 
1537  if( convertTo == SCH_TEXT_T )
1538  {
1539  if( newtext->IsDangling() )
1540  {
1541  newtext->SetIsDangling( false );
1542  getView()->Update( newtext, KIGFX::REPAINT );
1543  }
1544  }
1545  else
1547 
1548  m_frame->OnModify();
1549  }
1550  }
1551 
1552  if( selection.IsHover() )
1554 
1555  return 0;
1556 }
bool IsDangling() const override
Definition: sch_text.h:302
bool IsBold() const
Definition: eda_text.h:182
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:239
bool IsHover() const
Definition: selection.h:71
bool IsSelected() const
Definition: base_struct.h:207
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
void SetItalic(bool isItalic)
Definition: eda_text.h:178
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
void SetIsDangling(bool aIsDangling)
Definition: sch_text.h:303
int GetTextThickness() const
Definition: eda_text.h:158
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool IsNew() const
Definition: base_struct.h:203
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:60
bool IsItalic() const
Definition: eda_text.h:179
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
Item is being added to the view.
Definition: view_item.h:60
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:239
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
const wxPoint GetPosition() const override
Definition: sch_text.h:313
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:244
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
const wxSize & GetTextSize() const
Definition: eda_text.h:238
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:232
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
These Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which ar...
Definition: string.cpp:50
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:157
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
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:233
void SetBold(bool aBold)
Definition: eda_text.h:181
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:237
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

References EE_ACTIONS::addItemToSel, SCH_BASE_FRAME::AddToScreen(), EE_ACTIONS::clearSelection, CTX_NETNAME, EOT, EscapeString(), Format(), EDA_ITEM::GetEditFlags(), SELECTION::GetItem(), SCH_TEXT::GetLabelSpinStyle(), SCH_TEXT::GetPosition(), SCH_TEXT::GetShape(), SELECTION::GetSize(), EDA_TEXT::GetText(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetTextThickness(), TOOL_BASE::getView(), EDA_TEXT::IsBold(), SCH_TEXT::IsDangling(), SELECTION::IsHover(), EDA_TEXT::IsItalic(), EDA_ITEM::IsNew(), EDA_ITEM::IsSelected(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), TOOL_EVENT::Parameter(), SCH_BASE_FRAME::RemoveFromScreen(), EE_ACTIONS::removeItemFromSel, KIGFX::REPAINT, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_TEXT_T, EDA_TEXT::SetBold(), EDA_ITEM::SetFlags(), SCH_TEXT::SetIsDangling(), EDA_TEXT::SetItalic(), SCH_TEXT::SetLabelSpinStyle(), SCH_TEXT::SetShape(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), SCH_EDIT_FRAME::TestDanglingEnds(), EDA_ITEM::Type(), UnescapeString(), KIGFX::VIEW::Update(), UR_DELETED, and UR_NEW.

Referenced by setTransitions().

◆ CleanupSheetPins()

int SCH_EDIT_TOOL::CleanupSheetPins ( const TOOL_EVENT aEvent)

Definition at line 1578 of file sch_edit_tool.cpp.

1579 {
1581  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1582 
1583  if( !sheet )
1584  return 0;
1585 
1586  if( !sheet->HasUndefinedPins() )
1587  {
1588  DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
1589  return 0;
1590  }
1591 
1592  if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
1593  return 0;
1594 
1596 
1597  sheet->CleanupSheet();
1598 
1599  m_frame->GetScreen()->Update( sheet );
1600  updateView( sheet );
1601  m_frame->OnModify();
1602 
1603  if( selection.IsHover() )
1605 
1606  return 0;
1607 }
bool IsHover() const
Definition: selection.h:71
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:48
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:453
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:351
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
#define _(s)
Definition: 3d_actions.cpp:33
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)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:302
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:283
EDA_ITEM * Front() const
Definition: selection.h:184

References _, SCH_SHEET::CleanupSheet(), EE_ACTIONS::clearSelection, DisplayInfoMessage(), SELECTION::Front(), SCH_EDIT_FRAME::GetScreen(), SCH_SHEET::HasUndefinedPins(), SELECTION::IsHover(), IsOK(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyInUndoList(), EE_COLLECTOR::SheetsOnly, SCH_SCREEN::Update(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView(), and UR_CHANGED.

Referenced by setTransitions().

◆ ConvertDeMorgan()

int SCH_EDIT_TOOL::ConvertDeMorgan ( const TOOL_EVENT aEvent)

Definition at line 1211 of file sch_edit_tool.cpp.

1212 {
1214 
1215  if( selection.Empty() )
1216  return 0;
1217 
1218  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1219 
1221  && component->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
1222  return 0;
1223 
1225  && component->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
1226  return 0;
1227 
1228  if( !component->IsNew() )
1229  m_frame->SaveCopyInUndoList( component, UR_CHANGED );
1230 
1231  m_frame->ConvertPart( component );
1232 
1233  if( component->IsNew() )
1235 
1236  if( selection.IsHover() )
1238 
1239  return 0;
1240 }
bool IsHover() const
Definition: selection.h:71
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:128
bool IsNew() const
Definition: base_struct.h:203
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:127
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
Schematic symbol object.
Definition: sch_component.h:88
int GetConvert() const
void ConvertPart(SCH_COMPONENT *aComponent)
Definition: getpart.cpp:235
static TOOL_ACTION refreshPreview
Definition: actions.h:101
EDA_ITEM * Front() const
Definition: selection.h:184

References EE_ACTIONS::clearSelection, EE_COLLECTOR::ComponentsOnly, SCH_EDIT_FRAME::ConvertPart(), SELECTION::Empty(), SELECTION::Front(), SCH_COMPONENT::GetConvert(), TOOL_EVENT::IsAction(), SELECTION::IsHover(), EDA_ITEM::IsNew(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyInUndoList(), EE_ACTIONS::showDeMorganAlternate, EE_ACTIONS::showDeMorganStandard, and UR_CHANGED.

Referenced by setTransitions().

◆ DeleteItemCursor()

int SCH_EDIT_TOOL::DeleteItemCursor ( const TOOL_EVENT aEvent)

Runs the deletion tool.

Definition at line 1025 of file sch_edit_tool.cpp.

1026 {
1027  std::string tool = aEvent.GetCommandStr().get();
1028  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1029 
1031  m_pickerItem = nullptr;
1032 
1033  // Deactivate other tools; particularly important if another PICKER is currently running
1034  Activate();
1035 
1036  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
1037 
1038  picker->SetClickHandler(
1039  [this] ( const VECTOR2D& aPosition ) -> bool
1040  {
1041  if( m_pickerItem )
1042  {
1043  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
1044 
1045  if( sch_item && sch_item->IsLocked() )
1046  {
1047  STATUS_TEXT_POPUP statusPopup( m_frame );
1048  statusPopup.SetText( _( "Item locked." ) );
1049  statusPopup.PopupFor( 2000 );
1050  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1051  return true;
1052  }
1053 
1055  selectionTool->UnbrightenItem( m_pickerItem );
1056  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
1058  m_pickerItem = nullptr;
1059  }
1060 
1061  return true;
1062  } );
1063 
1064  picker->SetMotionHandler(
1065  [this] ( const VECTOR2D& aPos )
1066  {
1067  EE_COLLECTOR collector;
1068  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1069  collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
1070 
1072  selectionTool->GuessSelectionCandidates( collector, aPos );
1073 
1074  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
1075 
1076  if( m_pickerItem != item )
1077  {
1078  if( m_pickerItem )
1079  selectionTool->UnbrightenItem( m_pickerItem );
1080 
1081  m_pickerItem = item;
1082 
1083  if( m_pickerItem )
1084  selectionTool->BrightenItem( m_pickerItem );
1085  }
1086  } );
1087 
1088  picker->SetFinalizeHandler(
1089  [this] ( const int& aFinalState )
1090  {
1091  if( m_pickerItem )
1093  } );
1094 
1095  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1096 
1097  return 0;
1098 }
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
#define HITTEST_THRESHOLD_PIXELS
int m_Threshold
Definition: collector.h:66
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
static TOOL_ACTION doDelete
Definition: actions.h:74
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:72
void Collect(SCH_SCREEN *aScreen, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Function Collect scans a EDA_ITEM using this class's Inspector method, which does the collection.
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
EE_COLLECTOR.
Definition: ee_collectors.h:42
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
static TOOL_ACTION pickerTool
Definition: actions.h:148
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:102
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:100
void BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void UnbrightenItem(EDA_ITEM *aItem)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:89
virtual bool IsLocked() const
Function IsLocked.
Definition: sch_item.h:229
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static KICAD_T deletableItems[]
int AddItemToSel(const TOOL_EVENT &aEvent)
#define _(s)
Definition: 3d_actions.cpp:33
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
void Activate()
Function Activate() Runs the tool.
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151

References _, TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::BrightenItem(), EE_ACTIONS::clearSelection, EE_COLLECTOR::Collect(), deletableItems, ACTIONS::doDelete, TOOL_EVENT::GetCommandStr(), COLLECTOR::GetCount(), SCH_EDIT_FRAME::GetScreen(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), EE_SELECTION_TOOL::GuessSelectionCandidates(), HITTEST_THRESHOLD_PIXELS, SCH_ITEM::IsLocked(), KiROUND(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_pickerItem, COLLECTOR::m_Threshold, TOOL_BASE::m_toolMgr, STATUS_POPUP::Move(), ACTIONS::pickerTool, STATUS_POPUP::PopupFor(), TOOL_MANAGER::RunAction(), PICKER_TOOL::SetClickHandler(), PICKER_TOOL::SetCursor(), PICKER_TOOL::SetFinalizeHandler(), PICKER_TOOL::SetMotionHandler(), STATUS_TEXT_POPUP::SetText(), and EE_SELECTION_TOOL::UnbrightenItem().

Referenced by setTransitions().

◆ DoDelete()

int SCH_EDIT_TOOL::DoDelete ( const TOOL_EVENT aEvent)

Deletes the selected items, or the item under the cursor.

Definition at line 946 of file sch_edit_tool.cpp.

947 {
948  SCH_SCREEN* screen = m_frame->GetScreen();
950  bool appendToUndo = false;
951  std::vector<wxPoint> pts;
952 
953  if( items.empty() )
954  return 0;
955 
956  // Don't leave a freed pointer in the selection
958 
959  for( EDA_ITEM* item : items )
960  item->ClearFlags( STRUCT_DELETED );
961 
962  for( EDA_ITEM* item : items )
963  {
964  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
965 
966  if( !sch_item )
967  continue;
968 
969  if( sch_item->Type() == SCH_JUNCTION_T )
970  {
971  sch_item->SetFlags( STRUCT_DELETED );
972  sch_item->GetConnectionPoints( pts );
973 
974  // clean up junctions at the end
975  }
976  else
977  {
978  sch_item->SetFlags( STRUCT_DELETED );
979  saveCopyInUndoList( item, UR_DELETED, appendToUndo );
980  appendToUndo = true;
981 
982  if( sch_item && sch_item->IsConnectable() )
983  sch_item->GetConnectionPoints( pts );
984 
985  updateView( sch_item );
986 
987  if( sch_item->Type() == SCH_SHEET_PIN_T )
988  {
989  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
990  SCH_SHEET* sheet = pin->GetParent();
991 
992  sheet->RemovePin( pin );
993  }
994  else
995  m_frame->RemoveFromScreen( sch_item );
996 
997  if( sch_item->Type() == SCH_SHEET_T )
999  }
1000  }
1001 
1002  for( auto point : pts )
1003  {
1004  SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
1005 
1006  if( !junction )
1007  continue;
1008 
1009  if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsJunctionNeeded( point ) )
1010  m_frame->DeleteJunction( junction, appendToUndo );
1011  }
1012 
1014 
1015  m_frame->GetCanvas()->Refresh();
1016  m_frame->OnModify();
1017 
1018  return 0;
1019 }
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:352
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
Definition: sch_sheet.h:168
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:436
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_item.h:362
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:286
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:239
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:132
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
static KICAD_T deletableItems[]
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
void DeleteJunction(SCH_ITEM *aItem, bool aAppend=false)
Removes a given junction and heals any wire segments under the junction.
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:117
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T)
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:374
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:242
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

References EE_ACTIONS::clearSelection, deletableItems, SCH_EDIT_FRAME::DeleteJunction(), SCH_BASE_FRAME::GetCanvas(), SCH_ITEM::GetConnectionPoints(), SCH_SCREEN::GetItem(), SELECTION::GetItems(), SCH_SHEET_PIN::GetParent(), SCH_EDIT_FRAME::GetScreen(), EDA_ITEM::HasFlag(), SCH_ITEM::IsConnectable(), SCH_SCREEN::IsJunctionNeeded(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), SCH_BASE_FRAME::RemoveFromScreen(), SCH_SHEET::RemovePin(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_JUNCTION_T, SCH_SHEET_PIN_T, SCH_SHEET_T, EDA_ITEM::SetFlags(), STRUCT_DELETED, SCH_EDIT_FRAME::TestDanglingEnds(), EDA_ITEM::Type(), SCH_EDIT_FRAME::UpdateHierarchyNavigator(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView(), and UR_DELETED.

Referenced by setTransitions().

◆ Duplicate()

int SCH_EDIT_TOOL::Duplicate ( const TOOL_EVENT aEvent)

Definition at line 756 of file sch_edit_tool.cpp.

757 {
759 
760  if( selection.GetSize() == 0 )
761  return 0;
762 
763  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
764  // up dragging around a stack of objects...
765  if( selection.Front()->IsNew() )
766  return 0;
767 
768  EDA_ITEMS newItems;
769 
770  // Keep track of existing sheet paths. Duplicating a selection can modify this list
771  bool copiedSheets = false;
772  SCH_SHEET_LIST initial_sheetpathList = m_frame->Schematic().GetSheets();
773 
774  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
775  {
776  SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
777  SCH_ITEM* newItem = oldItem->Duplicate();
778  newItem->SetFlags( IS_NEW );
779  newItems.push_back( newItem );
780  saveCopyInUndoList( newItem, UR_NEW, ii > 0 );
781 
782  switch( newItem->Type() )
783  {
784  case SCH_JUNCTION_T:
785  case SCH_LINE_T:
786  case SCH_BUS_BUS_ENTRY_T:
788  case SCH_TEXT_T:
789  case SCH_LABEL_T:
790  case SCH_GLOBAL_LABEL_T:
791  case SCH_HIER_LABEL_T:
792  case SCH_NO_CONNECT_T:
793  newItem->SetParent( m_frame->GetScreen() );
794  m_frame->AddToScreen( newItem );
795  break;
796 
797  case SCH_SHEET_T:
798  {
799  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
800  SCH_SHEET* sheet = (SCH_SHEET*) newItem;
801  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
802  wxString baseName = nameField.GetText();
803  wxString candidateName = baseName;
804  int uniquifier = 1;
805 
806  while( hierarchy.NameExists( candidateName ) )
807  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
808 
809  nameField.SetText( candidateName );
810 
811  sheet->SetParent( m_frame->GetCurrentSheet().Last() );
812  m_frame->AddToScreen( sheet );
813 
814  copiedSheets = true;
815  break;
816  }
817 
818  case SCH_COMPONENT_T:
819  {
820  SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
821  component->ClearAnnotation( NULL );
822  component->SetParent( m_frame->GetScreen() );
823  m_frame->AddToScreen( component );
824  break;
825  }
826 
827  default:
828  break;
829  }
830  }
831 
832  if( copiedSheets )
833  {
834  // We clear annotation of new sheet paths.
835  // Annotation of new components added in current sheet is already cleared.
836  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
837  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
839  }
840 
842  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
844 
845  return 0;
846 }
SCH_SHEET_LIST.
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:99
static KICAD_T duplicatableItems[]
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:200
bool IsNew() const
Definition: base_struct.h:203
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:239
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:78
#define NULL
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:594
SCHEMATIC & Schematic() const
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
bool NameExists(const wxString &aSheetName)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
SCH_SHEET & Root() const
Definition: schematic.h:104
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Schematic symbol object.
Definition: sch_component.h:88
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:117
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION move
Definition: ee_actions.h:114
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:559
EDA_ITEM * Front() const
Definition: selection.h:184

References EE_ACTIONS::addItemsToSel, SCH_BASE_FRAME::AddToScreen(), SCH_COMPONENT::ClearAnnotation(), SCH_SCREENS::ClearAnnotationOfNewSheetPaths(), EE_ACTIONS::clearSelection, duplicatableItems, SCH_ITEM::Duplicate(), Format(), SELECTION::Front(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET::GetFields(), SELECTION::GetItem(), SCH_EDIT_FRAME::GetScreen(), SCHEMATIC::GetSheets(), SELECTION::GetSize(), EDA_TEXT::GetText(), IS_NEW, EDA_ITEM::IsNew(), SCH_SHEET_PATH::Last(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_ACTIONS::move, SCH_SHEET_LIST::NameExists(), NULL, EE_SELECTION_TOOL::RequestSelection(), SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_NO_CONNECT_T, SCH_SHEET_T, SCH_TEXT_T, SCH_EDIT_FRAME::Schematic(), EDA_ITEM::SetFlags(), EDA_ITEM::SetParent(), SCH_EDIT_FRAME::SetSheetNumberAndCount(), EDA_TEXT::SetText(), SHEETNAME, and UR_NEW.

Referenced by setTransitions().

◆ EditField()

int SCH_EDIT_TOOL::EditField ( const TOOL_EVENT aEvent)

Definition at line 1126 of file sch_edit_tool.cpp.

1127 {
1128  static KICAD_T Nothing[] = { EOT };
1129  static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_COMPONENT_T, EOT };
1130  static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_COMPONENT_T, EOT };
1131  static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_COMPONENT_T, EOT };
1132 
1133  KICAD_T* filter = Nothing;
1134 
1135  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1136  filter = CmpOrReference;
1137  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1138  filter = CmpOrValue;
1139  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1140  filter = CmpOrFootprint;
1141 
1142  EE_SELECTION& selection = m_selectionTool->RequestSelection( filter );
1143 
1144  if( selection.Empty() )
1145  return 0;
1146 
1147  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1148 
1149  if( item->Type() == SCH_COMPONENT_T )
1150  {
1151  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1152 
1153  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1154  editFieldText( component->GetField( REFERENCE ) );
1155  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1156  editFieldText( component->GetField( VALUE ) );
1157  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1158  editFieldText( component->GetField( FOOTPRINT ) );
1159  }
1160  else if( item->Type() == SCH_FIELD_T )
1161  {
1162  editFieldText( (SCH_FIELD*) item );
1163  }
1164 
1165  if( selection.IsHover() )
1167 
1168  return 0;
1169 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
bool IsHover() const
Definition: selection.h:71
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void editFieldText(SCH_FIELD *aField)
#define VALUE
static TOOL_ACTION editFootprint
Definition: ee_actions.h:124
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
static TOOL_ACTION editValue
Definition: ee_actions.h:123
Schematic symbol object.
Definition: sch_component.h:88
static TOOL_ACTION editReference
Definition: ee_actions.h:122
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

References EE_ACTIONS::clearSelection, editFieldText(), EE_ACTIONS::editFootprint, EE_ACTIONS::editReference, EE_ACTIONS::editValue, SELECTION::Empty(), EOT, FOOTPRINT, SELECTION::Front(), SCH_COMPONENT::GetField(), TOOL_EVENT::IsAction(), SELECTION::IsHover(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, REFERENCE, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_COMPONENT_T, SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_FIELD_LOCATE_REFERENCE_T, SCH_FIELD_LOCATE_VALUE_T, SCH_FIELD_T, EDA_ITEM::Type(), and VALUE.

Referenced by setTransitions().

◆ editFieldText()

void SCH_EDIT_TOOL::editFieldText ( SCH_FIELD aField)
private

Definition at line 1101 of file sch_edit_tool.cpp.

1102 {
1103  // Save old component in undo list if not already in edit, or moving.
1104  if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
1106 
1107  wxString title = wxString::Format( _( "Edit %s Field" ), aField->GetName() );
1108 
1109  DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, title, aField );
1110 
1111  // The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
1112  if( dlg.ShowQuasiModal() != wxID_OK )
1113  return;
1114 
1115  dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
1116 
1117  if( m_frame->eeconfig()->m_AutoplaceFields.enable || aField->GetParent()->Type() == SCH_SHEET_T )
1118  static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
1119 
1121  m_frame->RefreshItem( aField );
1122  m_frame->OnModify();
1123 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:206
EESCHEMA_SETTINGS * eeconfig() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
AUTOPLACE_FIELDS m_AutoplaceFields
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:244
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EDA_ITEM * GetParent() const
Definition: base_struct.h:199
DIALOG_SCH_EDIT_ONE_FIELD is a the class to handle editing a single component field in the schematic ...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
#define _(s)
Definition: 3d_actions.cpp:33
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:420
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

References _, SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, Format(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_ITEM::GetEditFlags(), SCH_FIELD::GetName(), EDA_ITEM::GetParent(), SCH_EDIT_FRAME::GetScreen(), EESCHEMA_SETTINGS::m_AutoplaceFields, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), SCH_BASE_FRAME::RefreshItem(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SHEET_T, EVENTS::SelectedItemsModified, EDA_ITEM::Type(), and UR_CHANGED.

Referenced by EditField(), and Properties().

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 187 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122  {
123  return m_toolId;
124  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

202  {
203  EDA_ITEM* m = getModelInt();
204 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
205  wxASSERT( dynamic_cast<T*>( m ) );
206 #endif
207  return static_cast<T*>( m );
208  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:54
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

133  {
134  return m_toolName;
135  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:218

References TOOL_BASE::m_toolName.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

111  {
112  return m_type;
113  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:211

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), ChangeTextType(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), COMMON_TOOLS::GridPreset(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ GlobalEdit()

int SCH_EDIT_TOOL::GlobalEdit ( const TOOL_EVENT aEvent)

◆ Go()

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

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 129 of file tool_interactive.h.

131 {
132  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
133 
134  goInternal( sptr, aConditions );
135 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), LIB_PIN_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), SCH_MOVE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), PL_EDIT_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCBNEW_CONTROL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), FOOTPRINT_EDITOR_TOOLS::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), DRC::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool SCH_EDIT_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

Definition at line 130 of file sch_edit_tool.cpp.

131 {
133 
136 
137  wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
138 
139  auto sheetTool =
140  [ this ] ( const SELECTION& aSel )
141  {
143  };
144 
145  auto anyTextTool =
146  [ this ] ( const SELECTION& aSel )
147  {
152  };
153 
154  auto duplicateCondition =
155  [] ( const SELECTION& aSel )
156  {
158  return false;
159 
160  return true;
161  };
162 
163  auto orientCondition =
164  [] ( const SELECTION& aSel )
165  {
166  if( aSel.Empty() )
167  return false;
168 
170  return false;
171 
172  SCH_ITEM* item = (SCH_ITEM*) aSel.Front();
173 
174  if( aSel.GetSize() > 1 )
175  return true;
176 
177  switch( item->Type() )
178  {
179  case SCH_MARKER_T:
180  case SCH_JUNCTION_T:
181  case SCH_NO_CONNECT_T:
182  case SCH_LINE_T:
183  case SCH_PIN_T:
184  return false;
185  default:
186  return true;
187  }
188  };
189 
190  auto propertiesCondition =
191  []( const SELECTION& aSel )
192  {
193  if( aSel.GetSize() == 0 )
194  return true; // Show worksheet properties
195 
196  if( aSel.GetSize() != 1
197  && !( aSel.GetSize() >= 1 && aSel.Front()->Type() == SCH_LINE_T
198  && aSel.AreAllItemsIdentical() ) )
199  return false;
200 
201  EDA_ITEM* firstItem = static_cast<EDA_ITEM*>( aSel.Front() );
202 
203  switch( firstItem->Type() )
204  {
205  case SCH_COMPONENT_T:
206  case SCH_SHEET_T:
207  case SCH_SHEET_PIN_T:
208  case SCH_TEXT_T:
209  case SCH_LABEL_T:
210  case SCH_GLOBAL_LABEL_T:
211  case SCH_HIER_LABEL_T:
212  case SCH_FIELD_T:
213  case SCH_BITMAP_T:
214  return aSel.GetSize() == 1;
215 
216  case SCH_LINE_T:
217  for( EDA_ITEM* item : aSel.GetItems() )
218  {
219  SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
220 
221  if( !line || !line->IsGraphicLine() )
222  return false;
223  }
224 
225  return true;
226 
227  default:
228  return false;
229  }
230  };
231 
232  static KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
233  auto toLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes );
234 
235  static KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT };
236  auto toHLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toHLableTypes );
237 
238  static KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
239  auto toGLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toGLableTypes );
240 
241  static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
242  auto toTextlCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes );
243 
244  static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT };
245  auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
246 
247  auto singleComponentCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_COMPONENT_T );
248  auto wireSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_WIRE_T );
249  auto busSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T );
250  auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
251 
252  //
253  // Add edit actions to the move tool menu
254  //
255  if( moveTool )
256  {
257  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
258 
259  moveMenu.AddSeparator();
260  moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
261  moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
262  moveMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition );
263  moveMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition );
265 
266  moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
267  moveMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition );
268  moveMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition );
269  moveMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition );
271 
272  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
273  symUnitMenu->SetTool( this );
274  m_menu.AddSubMenu( symUnitMenu );
275  moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
276 
277  moveMenu.AddSeparator();
280  moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
281  }
282 
283  //
284  // Add editing actions to the drawing tool menu
285  //
286  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
287 
288  drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
289  drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
290  drawMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
291  drawMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
292 
293  drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
294  drawMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition, 200 );
295  drawMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition, 200 );
296  drawMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition, 200 );
297  drawMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
299 
300  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
301  symUnitMenu2->SetTool( drawingTools );
302  drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
303  drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
304 
305  drawMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleComponentCondition && E_C::Idle, 200 );
306 
307  drawMenu.AddItem( EE_ACTIONS::toShapeSlash, entryCondition, 200 );
308  drawMenu.AddItem( EE_ACTIONS::toShapeBackslash, entryCondition, 200 );
309  drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
310  drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
311  drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
312  drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
313  drawMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetTool && E_C::Idle, 250 );
314 
315  //
316  // Add editing actions to the selection tool menu
317  //
319 
320  selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
321  selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
322  selToolMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
323  selToolMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
324  selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 200 );
325 
326  selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
328  selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
330  selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
332 
333  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
334  symUnitMenu3->SetTool( m_selectionTool );
335  m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
336  selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
337 
338  selToolMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleComponentCondition && E_C::Idle, 200 );
339 
340  selToolMenu.AddItem( EE_ACTIONS::toShapeSlash, entryCondition, 200 );
341  selToolMenu.AddItem( EE_ACTIONS::toShapeBackslash, entryCondition, 200 );
342  selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
343  selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
344  selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
345  selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 );
346  selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, singleSheetCondition, 250 );
347 
348  selToolMenu.AddSeparator( 300 );
349  selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
350  selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
351  selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
352  selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
353  selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
354 
355  return true;
356 }
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
static TOOL_ACTION properties
Definition: ee_actions.h:121
bool IsCurrentTool(const TOOL_ACTION &aAction) const
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
bool IsGraphicLine() const
Returns if the line is a graphic (non electrical line)
Definition: sch_line.cpp:817
static TOOL_ACTION toggleDeMorgan
Definition: ee_actions.h:126
static SELECTION_CONDITION SingleSymbol
static TOOL_ACTION doDelete
Definition: actions.h:74
SCH_DRAWING_TOOLS.
static TOOL_ACTION toShapeBackslash
Definition: ee_actions.h:131
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION mirrorY
Definition: ee_actions.h:120
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:88
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static SELECTION_CONDITION IdleSelection
TOOL_MENU & GetToolMenu()
static TOOL_ACTION toText
Definition: ee_actions.h:135
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:125
static SELECTION_CONDITION Idle
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
static TOOL_ACTION drawSheet
Definition: ee_actions.h:89
static SELECTION_CONDITION SingleDeMorganSymbol
static TOOL_ACTION copy
Definition: actions.h:70
static TOOL_ACTION cleanupSheetPins
Definition: ee_actions.h:183
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
static TOOL_ACTION editFootprint
Definition: ee_actions.h:124
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:92
static TOOL_ACTION cut
Definition: actions.h:69
static TOOL_ACTION mirrorX
Definition: ee_actions.h:119
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static SELECTION_CONDITION SingleMultiUnitSymbol
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
static TOOL_ACTION placeLabel
Definition: ee_actions.h:86
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
static TOOL_ACTION editValue
Definition: ee_actions.h:123
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Function CreateSubMenu.
Definition: tool_menu.cpp:52
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:158
static TOOL_ACTION toLabel
Definition: ee_actions.h:132
static TOOL_ACTION toHLabel
Definition: ee_actions.h:133
static TOOL_ACTION editReference
Definition: ee_actions.h:122
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:87
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
static TOOL_ACTION toGLabel
Definition: ee_actions.h:134
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION toShapeSlash
Definition: ee_actions.h:130
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), CONDITIONAL_MENU::AddSeparator(), TOOL_MENU::AddSubMenu(), EE_ACTIONS::autoplaceFields, EE_ACTIONS::cleanupSheetPins, ACTIONS::copy, SELECTION_CONDITIONS::Count(), ACTIONS::cut, ACTIONS::doDelete, EE_ACTIONS::drawSheet, ACTIONS::duplicate, EE_ACTIONS::editFootprint, EE_ACTIONS::editReference, EE_ACTIONS::editValue, EE_ACTIONS::editWithLibEdit, EOT, TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), EE_CONDITIONS::Idle, EE_CONDITIONS::IdleSelection, EE_TOOL_BASE< T >::Init(), TOOLS_HOLDER::IsCurrentTool(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), SCH_LINE::IsGraphicLine(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_INTERACTIVE::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_ACTIONS::mirrorX, EE_ACTIONS::mirrorY, SELECTION_CONDITIONS::MoreThan(), SELECTION_CONDITIONS::NotEmpty(), SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), ACTIONS::paste, ACTIONS::pasteSpecial, EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, EE_ACTIONS::placeLabel, EE_ACTIONS::placeSchematicText, EE_ACTIONS::properties, EE_ACTIONS::rotateCCW, EE_ACTIONS::rotateCW, SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_LOCATE_BUS_T, SCH_LINE_LOCATE_WIRE_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_PIN_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_TEXT_T, EE_CONDITIONS::SingleDeMorganSymbol, EE_CONDITIONS::SingleMultiUnitSymbol, EE_CONDITIONS::SingleSymbol, EE_ACTIONS::toggleDeMorgan, EE_ACTIONS::toGLabel, EE_ACTIONS::toHLabel, EE_ACTIONS::toLabel, EE_ACTIONS::toShapeBackslash, EE_ACTIONS::toShapeSlash, EE_ACTIONS::toText, and EDA_ITEM::Type().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

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

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

◆ Mirror()

int SCH_EDIT_TOOL::Mirror ( const TOOL_EVENT aEvent)

Definition at line 562 of file sch_edit_tool.cpp.

563 {
565 
566  if( selection.GetSize() == 0 )
567  return 0;
568 
569  wxPoint mirrorPoint;
570  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
571  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
572  bool connections = false;
573  bool moving = item->IsMoving();
574 
575  if( selection.GetSize() == 1 )
576  {
577  if( !moving )
579 
580  switch( item->Type() )
581  {
582  case SCH_COMPONENT_T:
583  {
584  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
585 
586  if( xAxis )
587  component->SetOrientation( CMP_MIRROR_X );
588  else
589  component->SetOrientation( CMP_MIRROR_Y );
590 
592  component->AutoAutoplaceFields( m_frame->GetScreen() );
593 
594  break;
595  }
596 
597  case SCH_TEXT_T:
598  case SCH_LABEL_T:
599  case SCH_GLOBAL_LABEL_T:
600  case SCH_HIER_LABEL_T:
601  {
602  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
603 
604  if( xAxis )
605  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorX() );
606  else
607  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorY() );
608  break;
609  }
610 
611  case SCH_SHEET_PIN_T:
612  {
613  // mirror within parent sheet
614  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
615  SCH_SHEET* sheet = pin->GetParent();
616 
617  if( xAxis )
618  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
619  else
620  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
621 
622  break;
623  }
624 
625  case SCH_BUS_BUS_ENTRY_T:
627  if( xAxis )
628  item->MirrorX( item->GetPosition().y );
629  else
630  item->MirrorY( item->GetPosition().x );
631  break;
632 
633  case SCH_FIELD_T:
634  {
635  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
636 
637  if( xAxis )
639  else
641 
642  // Now that we're re-justifying a field, they're no longer autoplaced.
643  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
644 
645  break;
646  }
647 
648  case SCH_BITMAP_T:
649  if( xAxis )
650  item->MirrorX( item->GetPosition().y );
651  else
652  item->MirrorY( item->GetPosition().x );
653 
654  // The bitmap is cached in Opengl: clear the cache to redraw
656  break;
657 
658  case SCH_SHEET_T:
659  // Mirror the sheet on itself. Sheets do not have a anchor point.
660  mirrorPoint = m_frame->GetNearestGridPosition( item->GetBoundingBox().Centre() );
661 
662  if( xAxis )
663  item->MirrorX( mirrorPoint.y );
664  else
665  item->MirrorY( mirrorPoint.x );
666 
667  break;
668 
669  default:
670  break;
671  }
672 
673  connections = item->IsConnectable();
674  m_frame->RefreshItem( item );
675  }
676  else if( selection.GetSize() > 1 )
677  {
678  mirrorPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
679 
680  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
681  {
682  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
683 
684  if( !moving )
685  saveCopyInUndoList( item, UR_CHANGED, ii > 0 );
686 
687  if( item->Type() == SCH_SHEET_PIN_T )
688  {
689  if( item->GetParent()->IsSelected() )
690  {
691  // parent will mirror us
692  }
693  else
694  {
695  // mirror within parent sheet
696  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
697  SCH_SHEET* sheet = pin->GetParent();
698 
699  if( xAxis )
700  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
701  else
702  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
703  }
704  }
705  else
706  {
707  if( xAxis )
708  item->MirrorX( mirrorPoint.y );
709  else
710  item->MirrorY( mirrorPoint.x );
711  }
712 
713  connections |= item->IsConnectable();
714  m_frame->RefreshItem( item );
715  }
716  }
717 
719 
720  if( item->IsMoving() )
721  {
723  }
724  else
725  {
726  if( selection.IsHover() )
728 
729  if( connections )
731 
732  m_frame->OnModify();
733  }
734 
735  return 0;
736 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:352
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsHover() const
Definition: selection.h:71
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
Definition: sch_sheet.h:168
bool IsSelected() const
Definition: base_struct.h:207
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:432
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:138
bool IsMoving() const
Definition: base_struct.h:204
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:206
virtual const wxPoint GetPosition() const
Definition: base_struct.h:344
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
AUTOPLACE_FIELDS m_AutoplaceFields
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_sheet.cpp:591
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:202
EDA_ITEM * GetParent() const
Definition: base_struct.h:199
const KICAD_T rotatableItems[]
static TOOL_ACTION mirrorX
Definition: ee_actions.h:119
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:232
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:364
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
virtual void MirrorX(int aXaxis_position)=0
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
virtual void MirrorY(int aYaxis_position)=0
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
LABEL_SPIN_STYLE MirrorY()
Definition: sch_text.h:127
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
LABEL_SPIN_STYLE MirrorX()
Definition: sch_text.h:108
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:201
Schematic symbol object.
Definition: sch_component.h:88
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:117
wxPoint Centre() const
Definition: eda_rect.h:62
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: base_struct.cpp:95
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:233
const wxPoint GetCenter() const
Definition: eda_rect.h:117
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
static TOOL_ACTION refreshPreview
Definition: actions.h:101
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

References SCH_ITEM::AutoAutoplaceFields(), EDA_RECT::Centre(), EE_ACTIONS::clearSelection, CMP_MIRROR_X, CMP_MIRROR_Y, SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, SELECTION::Front(), EDA_ITEM::GetBoundingBox(), SCH_SHEET::GetBoundingBox(), EDA_RECT::GetCenter(), SELECTION::GetCenter(), EDA_TEXT::GetHorizJustify(), SELECTION::GetItem(), SCH_TEXT::GetLabelSpinStyle(), EDA_DRAW_FRAME::GetNearestGridPosition(), SCH_SHEET_PIN::GetParent(), EDA_ITEM::GetParent(), EDA_ITEM::GetPosition(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), EDA_TEXT::GetVertJustify(), TOOL_BASE::getView(), SCH_ITEM::IsConnectable(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EESCHEMA_SETTINGS::m_AutoplaceFields, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_EVENT::Matches(), LABEL_SPIN_STYLE::MirrorX(), EE_ACTIONS::mirrorX, SCH_SHEET_PIN::MirrorX(), SCH_ITEM::MirrorX(), LABEL_SPIN_STYLE::MirrorY(), SCH_SHEET_PIN::MirrorY(), SCH_ITEM::MirrorY(), SCH_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), KIGFX::VIEW::RecacheAllItems(), SCH_BASE_FRAME::RefreshItem(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), rotatableItems, TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_TEXT_T, EVENTS::SelectedItemsModified, EDA_TEXT::SetHorizJustify(), SCH_TEXT::SetLabelSpinStyle(), SCH_COMPONENT::SetOrientation(), EDA_TEXT::SetVertJustify(), SCH_EDIT_FRAME::TestDanglingEnds(), EDA_ITEM::Type(), UR_CHANGED, wxPoint::x, and wxPoint::y.

Referenced by setTransitions().

◆ Properties()

int SCH_EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

Definition at line 1243 of file sch_edit_tool.cpp.

1244 {
1246 
1247  if( selection.Empty() )
1248  {
1250  {
1252  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1253 
1254  if( worksheet && worksheet->HitTestWorksheetItems( getView(), (wxPoint) cursorPos ) )
1256  }
1257 
1258  return 0;
1259  }
1260 
1261  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1262 
1263  switch( item->Type() )
1264  {
1265  case SCH_LINE_T:
1266  if( !selection.AreAllItemsIdentical() )
1267  return 0;
1268 
1269  break;
1270 
1271  default:
1272  if( selection.Size() > 1 )
1273  return 0;
1274 
1275  break;
1276  }
1277 
1278  switch( item->Type() )
1279  {
1280  case SCH_COMPONENT_T:
1281  {
1282  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1283  DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dlg( m_frame, component );
1284 
1285  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
1286  // frame. Therefore this dialog as a modal frame parent, MUST be run under
1287  // quasimodal mode for the quasimodal frame support to work. So don't use
1288  // the QUASIMODAL macros here.
1289  if( dlg.ShowQuasiModal() == wxID_OK )
1290  {
1292  component->AutoAutoplaceFields( m_frame->GetScreen() );
1293 
1295  m_frame->OnModify();
1296  }
1297  }
1298  break;
1299 
1300  case SCH_SHEET_T:
1301  {
1302  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1303  bool doClearAnnotation;
1304  bool doRefresh = false;
1305  // Keep track of existing sheet paths. EditSheet() can modify this list
1306  SCH_SHEET_LIST initial_sheetpathList = m_frame->Schematic().GetSheets();
1307 
1308  doRefresh = m_frame->EditSheetProperties(
1309  sheet, &m_frame->GetCurrentSheet(), &doClearAnnotation );
1310 
1311  // If the sheet file is changed and new sheet contents are loaded then we have to
1312  // clear the annotations on the new content (as it may have been set from some other
1313  // sheet path reference)
1314  if( doClearAnnotation )
1315  {
1316  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
1317  // We clear annotation of new sheet paths here:
1318  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1319  // Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
1320  // path, but components managed by its sheet path must have their annotation
1321  // cleared, because they are new:
1323  }
1324 
1325  if( doRefresh )
1326  {
1328  m_frame->GetCanvas()->Refresh();
1330  }
1331 
1332  break;
1333  }
1334 
1335  case SCH_SHEET_PIN_T:
1336  {
1337  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) item;
1338  DIALOG_EDIT_SHEET_PIN dlg( m_frame, pin );
1339 
1340  if( dlg.ShowModal() == wxID_OK )
1341  {
1343  m_frame->OnModify();
1344  }
1345  }
1346  break;
1347 
1348  case SCH_TEXT_T:
1349  case SCH_LABEL_T:
1350  case SCH_GLOBAL_LABEL_T:
1351  case SCH_HIER_LABEL_T:
1352  {
1353  DIALOG_LABEL_EDITOR dlg( m_frame, (SCH_TEXT*) item );
1354 
1355  if( dlg.ShowModal() == wxID_OK )
1356  {
1358  m_frame->OnModify();
1359  }
1360  }
1361  break;
1362 
1363  case SCH_FIELD_T:
1364  editFieldText( (SCH_FIELD*) item );
1365  break;
1366 
1367  case SCH_BITMAP_T:
1368  {
1369  SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
1370  DIALOG_IMAGE_EDITOR dlg( m_frame, bitmap->GetImage() );
1371 
1372  if( dlg.ShowModal() == wxID_OK )
1373  {
1374  // save old image in undo list if not already in edit
1375  if( bitmap->GetEditFlags() == 0 )
1377 
1378  dlg.TransferToImage( bitmap->GetImage() );
1379 
1380  // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1381  getView()->RecacheAllItems();
1383  m_frame->OnModify();
1384  }
1385  }
1386  break;
1387 
1388  case SCH_LINE_T:
1389  {
1390  std::deque<SCH_LINE*> lines;
1391 
1392  for( auto selItem : selection.Items() )
1393  {
1394  SCH_LINE* line = dynamic_cast<SCH_LINE*>( selItem );
1395 
1396  if( line )
1397  lines.push_back( line );
1398  else
1399  return 0;
1400  }
1401 
1402  DIALOG_EDIT_LINE_STYLE dlg( m_frame, lines );
1403 
1404  if( dlg.ShowModal() == wxID_OK )
1405  {
1407  m_frame->OnModify();
1408  }
1409  }
1410  break;
1411 
1412  case SCH_MARKER_T: // These items have no properties to edit
1413  case SCH_JUNCTION_T:
1414  case SCH_NO_CONNECT_T:
1415  break;
1416 
1417  default: // Unexpected item
1418  wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
1419  }
1420 
1421  m_frame->GetScreen()->Update( item );
1422  updateView( item );
1423 
1424  if( selection.IsHover() )
1426 
1427  return 0;
1428 }
SCH_SHEET_LIST.
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
bool IsHover() const
Definition: selection.h:71
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:189
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:99
static TOOL_ACTION pageSettings
Definition: actions.h:59
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:432
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
WS_PROXY_VIEW_ITEM * GetWorksheet() const
Definition: sch_view.h:101
bool AreAllItemsIdentical() const
Checks if all items in the selection are the same KICAD_T type.
Definition: selection.h:260
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:206
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void editFieldText(SCH_FIELD *aField)
bool HitTestWorksheetItems(VIEW *aView, const wxPoint &aPosition)
AUTOPLACE_FIELDS m_AutoplaceFields
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:244
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
SCH_SHEET & Root() const
Definition: schematic.h:104
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
Dialog used to edit SCH_COMPONENT objects in a schematic.
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
Schematic symbol object.
Definition: sch_component.h:88
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_item.h:178
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:482
SCH_SHEET_PATH & GetCurrentSheet() const
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:973
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)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:302
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
static const KICAD_T EditableItems[]
Definition: ee_collectors.h:46
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:559
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416

References SELECTION::AreAllItemsIdentical(), SCH_ITEM::AutoAutoplaceFields(), SCH_SCREEN::ClearAnnotation(), SCH_SCREENS::ClearAnnotationOfNewSheetPaths(), EE_ACTIONS::clearSelection, EE_COLLECTOR::EditableItems, editFieldText(), SCH_EDIT_FRAME::EditSheetProperties(), SCH_BASE_FRAME::eeconfig(), SELECTION::Empty(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, SELECTION::Front(), SCH_BASE_FRAME::GetCanvas(), SCH_FIELD::GetClass(), SCH_EDIT_FRAME::GetCurrentSheet(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EDA_ITEM::GetEditFlags(), SCH_BITMAP::GetImage(), SCH_EDIT_FRAME::GetScreen(), SCH_SHEET::GetScreen(), SCHEMATIC::GetSheets(), SCH_DRAW_PANEL::GetView(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), KIGFX::SCH_VIEW::GetWorksheet(), KIGFX::WS_PROXY_VIEW_ITEM::HitTestWorksheetItems(), SELECTION::IsHover(), KIGFX::VIEW::IsLayerVisible(), SELECTION::Items(), LAYER_SCHEMATIC_WORKSHEET, EESCHEMA_SETTINGS::m_AutoplaceFields, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), ACTIONS::pageSettings, TOOL_MANAGER::PostEvent(), KIGFX::VIEW::RecacheAllItems(), EDA_DRAW_PANEL_GAL::Refresh(), EE_SELECTION_TOOL::RequestSelection(), SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_BITMAP_T, SCH_COMPONENT_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_TEXT_T, SCH_EDIT_FRAME::Schematic(), EVENTS::SelectedItemsModified, DIALOG_SHIM::ShowQuasiModal(), SELECTION::Size(), EDA_ITEM::Type(), SCH_SCREEN::Update(), SCH_EDIT_FRAME::UpdateHierarchyNavigator(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView(), and UR_CHANGED.

Referenced by setTransitions().

◆ RepeatDrawItem()

int SCH_EDIT_TOOL::RepeatDrawItem ( const TOOL_EVENT aEvent)

Definition at line 849 of file sch_edit_tool.cpp.

850 {
851  SCH_ITEM* sourceItem = m_frame->GetRepeatItem();
852 
853  if( !sourceItem )
854  return 0;
855 
857 
858  SCH_ITEM* newItem = sourceItem->Duplicate();
859  bool performDrag = false;
860 
861  // If cloning a component then put into 'move' mode.
862  if( newItem->Type() == SCH_COMPONENT_T )
863  {
864  wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( true );
865  newItem->Move( cursorPos - newItem->GetPosition() );
866  performDrag = true;
867  }
868  else
869  {
870  if( m_isLibEdit )
871  {
872  LIBEDIT_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
873 
874  if( dynamic_cast<SCH_TEXT*>( newItem ) )
875  {
876  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
877  text->IncrementLabel( cfg->m_Repeat.label_delta );
878  }
879 
880  newItem->Move( wxPoint( Mils2iu( cfg->m_Repeat.x_step ),
881  Mils2iu( cfg->m_Repeat.y_step ) ) );
882  }
883  else
884  {
885  EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
886 
887  if( dynamic_cast<SCH_TEXT*>( newItem ) )
888  {
889  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
891  }
892 
893  newItem->Move( wxPoint( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ),
894  Mils2iu( cfg->m_Drawing.default_repeat_offset_y ) ) );
895  }
896 
897  }
898 
899  newItem->SetFlags( IS_NEW );
900  m_frame->AddToScreen( newItem );
901  m_frame->SaveCopyInUndoList( newItem, UR_NEW );
902 
903  m_selectionTool->AddItemToSel( newItem );
904 
905  if( performDrag )
907 
908  newItem->ClearFlags();
909 
910  if( newItem->IsConnectable() )
911  {
912  auto selection = m_selectionTool->GetSelection();
913 
914  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
917  }
918 
919  // newItem newItem, now that it has been moved, thus saving new position.
920  m_frame->SaveCopyForRepeatItem( newItem );
921 
922  return 0;
923 }
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:352
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual const wxPoint GetPosition() const
Definition: base_struct.h:344
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:239
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:78
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
SCH_ITEM * GetRepeatItem() const
Return the item which is to be repeated with the insert key.
int AddItemToSel(const TOOL_EVENT &aEvent)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:240
static TOOL_ACTION move
Definition: ee_actions.h:114
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
void IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:153
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.

References EE_SELECTION_TOOL::AddItemToSel(), EE_ACTIONS::addNeededJunctions, SCH_BASE_FRAME::AddToScreen(), EDA_ITEM::ClearFlags(), EE_ACTIONS::clearSelection, EESCHEMA_SETTINGS::DRAWING::default_repeat_offset_x, EESCHEMA_SETTINGS::DRAWING::default_repeat_offset_y, SCH_ITEM::Duplicate(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EDA_ITEM::GetPosition(), SCH_EDIT_FRAME::GetRepeatItem(), EE_SELECTION_TOOL::GetSelection(), TOOL_BASE::getViewControls(), SCH_TEXT::IncrementLabel(), IS_NEW, SCH_ITEM::IsConnectable(), LIBEDIT_SETTINGS::REPEAT::label_delta, EESCHEMA_SETTINGS::m_Drawing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isLibEdit, LIBEDIT_SETTINGS::m_Repeat, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_ACTIONS::move, SCH_ITEM::Move(), Pgm(), EESCHEMA_SETTINGS::DRAWING::repeat_label_increment, TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_COMPONENT_T, SCH_EDIT_FRAME::SchematicCleanUp(), EDA_ITEM::SetFlags(), SCH_EDIT_FRAME::TestDanglingEnds(), EDA_ITEM::Type(), UR_NEW, LIBEDIT_SETTINGS::REPEAT::x_step, and LIBEDIT_SETTINGS::REPEAT::y_step.

Referenced by setTransitions().

◆ Reset()

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

Function Reset() Brings the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 90 of file ee_tool_base.h.

91  {
92  if( aReason == MODEL_RELOAD )
93  {
94  // Init variables used by every drawing tool
95  m_frame = getEditFrame<T>();
96  m_isLibEdit = dynamic_cast<LIB_EDIT_FRAME*>( m_frame ) != nullptr;
97  }
98 
99  m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
100  }
Model changes (required full reload)
Definition: tool_base.h:82
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36

◆ Rotate()

int SCH_EDIT_TOOL::Rotate ( const TOOL_EVENT aEvent)

Definition at line 378 of file sch_edit_tool.cpp.

379 {
381 
382  if( selection.GetSize() == 0 )
383  return 0;
384 
385  wxPoint rotPoint;
386  bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
387  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
388  bool connections = false;
389  bool moving = item->IsMoving();
390 
391  if( selection.GetSize() == 1 )
392  {
393  if( !moving )
395 
396  switch( item->Type() )
397  {
398  case SCH_COMPONENT_T:
399  {
400  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
401 
402  if( clockwise )
403  component->SetOrientation( CMP_ROTATE_CLOCKWISE );
404  else
406 
408  component->AutoAutoplaceFields( m_frame->GetScreen() );
409 
410  break;
411  }
412 
413  case SCH_TEXT_T:
414  case SCH_LABEL_T:
415  case SCH_GLOBAL_LABEL_T:
416  case SCH_HIER_LABEL_T:
417  {
418  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
419 
420  if( clockwise )
421  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().RotateCW() );
422  else
423  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().RotateCCW() );
424 
425  break;
426  }
427 
428  case SCH_SHEET_PIN_T:
429  {
430  // Rotate pin within parent sheet
431  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
432  SCH_SHEET* sheet = pin->GetParent();
433  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
434  {
435  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
436  }
437  break;
438  }
439 
440  case SCH_BUS_BUS_ENTRY_T:
442  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
443  {
444  item->Rotate( item->GetPosition() );
445  }
446  break;
447 
448  case SCH_FIELD_T:
449  {
450  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
451 
452  if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
453  field->SetTextAngle( TEXT_ANGLE_VERT );
454  else
455  field->SetTextAngle( TEXT_ANGLE_HORIZ );
456 
457  // Now that we're moving a field, they're no longer autoplaced.
458  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
459 
460  break;
461  }
462 
463  case SCH_BITMAP_T:
464  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
465  {
466  item->Rotate( item->GetPosition() );
467  }
468  // The bitmap is cached in Opengl: clear the cache to redraw
470  break;
471 
472  case SCH_SHEET_T:
473  {
474  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
475 
476  // Rotate the sheet on itself. Sheets do not have an anchor point.
477  for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
478  {
479  rotPoint = m_frame->GetNearestGridPosition( sheet->GetRotationCenter() );
480  sheet->Rotate( rotPoint );
481  }
482  break;
483  }
484 
485  default:
486  break;
487  }
488 
489  connections = item->IsConnectable();
490  m_frame->RefreshItem( item );
491  }
492  else if( selection.GetSize() > 1 )
493  {
494  rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
495 
496  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
497  {
498  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
499 
500  if( !moving )
501  saveCopyInUndoList( item, UR_CHANGED, ii > 0 );
502 
503  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
504  {
505  if( item->Type() == SCH_LINE_T )
506  {
507  SCH_LINE* line = (SCH_LINE*) item;
508 
509  if( item->HasFlag( STARTPOINT ) )
510  line->RotateStart( rotPoint );
511 
512  if( item->HasFlag( ENDPOINT ) )
513  line->RotateEnd( rotPoint );
514  }
515  else if( item->Type() == SCH_SHEET_PIN_T )
516  {
517  if( item->GetParent()->IsSelected() )
518  {
519  // parent will rotate us
520  }
521  else
522  {
523  // rotate within parent
524  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
525  SCH_SHEET* sheet = pin->GetParent();
526 
527  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
528  }
529  }
530  else
531  {
532  item->Rotate( rotPoint );
533  }
534  }
535 
536  connections |= item->IsConnectable();
537  m_frame->RefreshItem( item );
538  }
539  }
540 
542 
543  if( item->IsMoving() )
544  {
546  }
547  else
548  {
549  if( selection.IsHover() )
551 
552  if( connections )
554 
555  m_frame->OnModify();
556  }
557 
558  return 0;
559 }
#define TEXT_ANGLE_HORIZ
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:352
bool IsHover() const
Definition: selection.h:71
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
Definition: sch_sheet.h:168
bool IsSelected() const
Definition: base_struct.h:207
#define TEXT_ANGLE_VERT
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:432
void RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:346
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:138
bool IsMoving() const
Definition: base_struct.h:204
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
double GetTextAngle() const
Definition: eda_text.h:173
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:206
void RotateStart(wxPoint aPosition)
Definition: sch_line.cpp:340
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
virtual const wxPoint GetPosition() const
Definition: base_struct.h:344
virtual void Rotate(wxPoint aPosition)=0
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
AUTOPLACE_FIELDS m_AutoplaceFields
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_sheet.cpp:591
EDA_ITEM * GetParent() const
Definition: base_struct.h:199
const KICAD_T rotatableItems[]
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:232
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:364
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:726
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
LABEL_SPIN_STYLE RotateCCW()
Definition: sch_text.h:89
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
LABEL_SPIN_STYLE RotateCW()
Definition: sch_text.h:73
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:123
Schematic symbol object.
Definition: sch_component.h:88
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:117
wxPoint GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
Definition: sch_sheet.cpp:602
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:166
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:242
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:233
const wxPoint GetCenter() const
Definition: eda_rect.h:117
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
static TOOL_ACTION refreshPreview
Definition: actions.h:101
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:122
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

References SCH_ITEM::AutoAutoplaceFields(), EE_ACTIONS::clearSelection, CMP_ROTATE_CLOCKWISE, CMP_ROTATE_COUNTERCLOCKWISE, SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, ENDPOINT, SELECTION::Front(), SCH_SHEET::GetBoundingBox(), EDA_RECT::GetCenter(), SELECTION::GetCenter(), SELECTION::GetItem(), SCH_TEXT::GetLabelSpinStyle(), EDA_DRAW_FRAME::GetNearestGridPosition(), SCH_SHEET_PIN::GetParent(), EDA_ITEM::GetParent(), EDA_ITEM::GetPosition(), SCH_SHEET::GetRotationCenter(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), EDA_TEXT::GetTextAngle(), TOOL_BASE::getView(), EDA_ITEM::HasFlag(), SCH_ITEM::IsConnectable(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EESCHEMA_SETTINGS::m_AutoplaceFields, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_EVENT::Matches(), SCH_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), KIGFX::VIEW::RecacheAllItems(), SCH_BASE_FRAME::RefreshItem(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), rotatableItems, SCH_SHEET_PIN::Rotate(), SCH_ITEM::Rotate(), SCH_SHEET::Rotate(), LABEL_SPIN_STYLE::RotateCCW(), LABEL_SPIN_STYLE::RotateCW(), EE_ACTIONS::rotateCW, SCH_LINE::RotateEnd(), SCH_LINE::RotateStart(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_LINE_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_TEXT_T, EVENTS::SelectedItemsModified, SCH_TEXT::SetLabelSpinStyle(), SCH_COMPONENT::SetOrientation(), EDA_TEXT::SetTextAngle(), STARTPOINT, SCH_EDIT_FRAME::TestDanglingEnds(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, EDA_ITEM::Type(), and UR_CHANGED.

Referenced by setTransitions().

◆ RunMainStack()

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

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ saveCopyInUndoList()

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

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

Definition at line 117 of file ee_tool_base.h.

118  {
119  KICAD_T itemType = aItem->Type();
120  bool selected = aItem->IsSelected();
121 
122  // IS_SELECTED flag should not be set on undo items which were added for
123  // a drag operation.
124  if( selected && aItem->HasFlag( TEMP_SELECTED ))
125  aItem->ClearSelected();
126 
127  if( m_isLibEdit )
128  {
129  LIB_EDIT_FRAME* editFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
130  wxASSERT( editFrame );
131 
132  editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
133  }
134  else
135  {
136  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
137  wxASSERT( editFrame );
138 
139  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
140  editFrame->SaveCopyInUndoList(
141  static_cast<SCH_ITEM*>( aItem->GetParent() ), UR_CHANGED, aAppend );
142  else
143  editFrame->SaveCopyInUndoList( static_cast<SCH_ITEM*>( aItem ), aType, aAppend );
144  }
145 
146  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
147  aItem->SetSelected();
148  }
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:125
bool IsSelected() const
Definition: base_struct.h:207
void ClearSelected()
Definition: base_struct.h:217
Schematic editor (Eeschema) main window.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
void SetSelected()
Definition: base_struct.h:213
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EDA_ITEM * GetParent() const
Definition: base_struct.h:199
The symbol library editor main window.
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:242
void SaveCopyInUndoList(EDA_ITEM *ItemToCopy, UNDO_REDO_T undoType=UR_LIBEDIT, bool aAppend=false)
Create a copy of the current component, and save it in the undo list.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void SCH_EDIT_TOOL::setTransitions ( )
overrideprivatevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 1610 of file sch_edit_tool.cpp.

1611 {
1616  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorX.MakeEvent() );
1617  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorY.MakeEvent() );
1618  Go( &SCH_EDIT_TOOL::DoDelete, ACTIONS::doDelete.MakeEvent() );
1620 
1630 
1637 
1640 
1643 }
static TOOL_ACTION properties
Definition: ee_actions.h:121
static TOOL_ACTION toggleDeMorgan
Definition: ee_actions.h:126
static TOOL_ACTION breakBus
Definition: ee_actions.h:137
static TOOL_ACTION doDelete
Definition: actions.h:74
static TOOL_ACTION toShapeBackslash
Definition: ee_actions.h:131
int Rotate(const TOOL_EVENT &aEvent)
static TOOL_ACTION mirrorY
Definition: ee_actions.h:120
int BreakWire(const TOOL_EVENT &aEvent)
static TOOL_ACTION toText
Definition: ee_actions.h:135
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:125
int Properties(const TOOL_EVENT &aEvent)
int UpdateFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:128
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION breakWire
Definition: ee_actions.h:136
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
int Duplicate(const TOOL_EVENT &aEvent)
static TOOL_ACTION cleanupSheetPins
Definition: ee_actions.h:183
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
static TOOL_ACTION editFootprint
Definition: ee_actions.h:124
int ChangeShape(const TOOL_EVENT &aEvent)
int AutoplaceFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:116
static TOOL_ACTION mirrorX
Definition: ee_actions.h:119
int CleanupSheetPins(const TOOL_EVENT &aEvent)
static TOOL_ACTION editTextAndGraphics
Definition: ee_actions.h:184
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:127
int Mirror(const TOOL_EVENT &aEvent)
int RepeatDrawItem(const TOOL_EVENT &aEvent)
static TOOL_ACTION updateFieldsFromLibrary
Definition: ee_actions.h:149
static TOOL_ACTION editValue
Definition: ee_actions.h:123
int EditField(const TOOL_EVENT &aEvent)
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION toLabel
Definition: ee_actions.h:132
static TOOL_ACTION toHLabel
Definition: ee_actions.h:133
static TOOL_ACTION editReference
Definition: ee_actions.h:122
int DoDelete(const TOOL_EVENT &aEvent)
Deletes the selected items, or the item under the cursor.
static TOOL_ACTION toGLabel
Definition: ee_actions.h:134
int ConvertDeMorgan(const TOOL_EVENT &aEvent)
static TOOL_ACTION duplicate
Definition: actions.h:73
int ChangeTextType(const TOOL_EVENT &aEvent)
Change a text type to another one.
static TOOL_ACTION toShapeSlash
Definition: ee_actions.h:130

References AutoplaceFields(), EE_ACTIONS::autoplaceFields, EE_ACTIONS::breakBus, BreakWire(), EE_ACTIONS::breakWire, ChangeShape(), ChangeTextType(), CleanupSheetPins(), EE_ACTIONS::cleanupSheetPins, ConvertDeMorgan(), DeleteItemCursor(), ACTIONS::deleteTool, ACTIONS::doDelete, DoDelete(), Duplicate(), ACTIONS::duplicate, EditField(), EE_ACTIONS::editFootprint, EE_ACTIONS::editReference, EE_ACTIONS::editTextAndGraphics, EE_ACTIONS::editValue, GlobalEdit(), TOOL_INTERACTIVE::Go(), Mirror(), EE_ACTIONS::mirrorX, EE_ACTIONS::mirrorY, Properties(), EE_ACTIONS::properties, RepeatDrawItem(), EE_ACTIONS::repeatDrawItem, Rotate(), EE_ACTIONS::rotateCCW, EE_ACTIONS::rotateCW, EE_ACTIONS::showDeMorganAlternate, EE_ACTIONS::showDeMorganStandard, EE_ACTIONS::toggleDeMorgan, EE_ACTIONS::toGLabel, EE_ACTIONS::toHLabel, EE_ACTIONS::toLabel, EE_ACTIONS::toShapeBackslash, EE_ACTIONS::toShapeSlash, EE_ACTIONS::toText, UpdateFields(), and EE_ACTIONS::updateFieldsFromLibrary.

◆ UpdateFields()

int SCH_EDIT_TOOL::UpdateFields ( const TOOL_EVENT aEvent)

Definition at line 1197 of file sch_edit_tool.cpp.

1198 {
1199  std::list<SCH_COMPONENT*> components;
1200 
1201  for( auto item : m_frame->GetScreen()->Items().OfType( SCH_COMPONENT_T ) )
1202  components.push_back( static_cast<SCH_COMPONENT*>( item ) );
1203 
1204  if( InvokeDialogUpdateFields( m_frame, components, true ) == wxID_OK )
1205  m_frame->GetCanvas()->Refresh();
1206 
1207  return 0;
1208 }
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int InvokeDialogUpdateFields(SCH_EDIT_FRAME *aCaller, const list< SCH_COMPONENT * > aComponents, bool aCreateUndoEntry)
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
EE_RTREE & Items()
Definition: sch_screen.h:162

References SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetScreen(), InvokeDialogUpdateFields(), SCH_SCREEN::Items(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_RTREE::OfType(), EDA_DRAW_PANEL_GAL::Refresh(), and SCH_COMPONENT_T.

Referenced by setTransitions().

◆ updateView()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView ( EDA_ITEM aItem) const
inlineprotectedinherited

Similar to getView()->Update(), but handles items that are redrawn by their parents.

Definition at line 104 of file ee_tool_base.h.

105  {
106  KICAD_T itemType = aItem->Type();
107 
108  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
109  getView()->Update( aItem->GetParent() );
110 
111  getView()->Update( aItem );
112  }
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
EDA_ITEM * GetParent() const
Definition: base_struct.h:199
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197

◆ Wait()

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

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_frame

SCH_EDIT_FRAME * EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame
protectedinherited

Definition at line 151 of file ee_tool_base.h.

◆ m_isLibEdit

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isLibEdit
protectedinherited

Definition at line 154 of file ee_tool_base.h.

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), Init(), PL_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), FOOTPRINT_EDITOR_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), EDA_3D_CONTROLLER::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_pickerItem

EDA_ITEM* SCH_EDIT_TOOL::m_pickerItem
private

Definition at line 89 of file sch_edit_tool.h.

Referenced by DeleteItemCursor(), and SCH_EDIT_TOOL().

◆ m_selectionTool

EE_SELECTION_TOOL* EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool
protectedinherited

Definition at line 153 of file ee_tool_base.h.

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 214 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), AutoplaceFields(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), ChangeShape(), ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), CleanupSheetPins(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), FOOTPRINT_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), Duplicate(), EDIT_TOOL::Duplicate(), EditField(), editFieldText(), EDIT_TOOL::EditFpInFpEditor(), LIB_EDIT_TOOL::editGraphicProperties(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), FOOTPRINT_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), Init(), PL_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LIB_CONTROL::Init(), PL_DRAWING_TOOLS::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

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

◆ m_view

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

Definition at line 152 of file ee_tool_base.h.


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