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 , REDRAW }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 SCH_EDIT_TOOL ()
 
 ~SCH_EDIT_TOOL () override
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
int Rotate (const TOOL_EVENT &aEvent)
 
int Mirror (const TOOL_EVENT &aEvent)
 
int Swap (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 ChangeSymbols (const TOOL_EVENT &aEvent)
 
int ConvertDeMorgan (const TOOL_EVENT &aEvent)
 
int EditPageNumber (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)
 Delete the selected items, or the item under the cursor. More...
 
int DoDelete (const TOOL_EVENT &aEvent)
 Run the deletion tool. More...
 
int DeleteItemCursor (const TOOL_EVENT &aEvent)
 
int DdAppendFile (const TOOL_EVENT &aEvent)
 Drag and drop. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Attributes

static const std::vector< KICAD_TRotatableItems
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

void editFieldText (SCH_FIELD *aField)
 Set up handlers for various events. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
void resetTransitions ()
 Clear the current transition map and restores the default one created by setTransitions(). More...
 
void goInternal (TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
 
EDA_ITEMgetModelInt () const
 
TOOLS_HOLDERgetToolHolderInt () const
 

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

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

REDRAW 

Full drawing refresh.

Definition at line 77 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ SCH_EDIT_TOOL()

SCH_EDIT_TOOL::SCH_EDIT_TOOL ( )

Definition at line 131 of file sch_edit_tool.cpp.

131 :
132 EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
133{
134 m_pickerItem = nullptr;
135}
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:93

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

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

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

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

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

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61{
62 m_toolMgr = aManager;
63}

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ AutoplaceFields()

int SCH_EDIT_TOOL::AutoplaceFields ( const TOOL_EVENT aEvent)

Definition at line 1452 of file sch_edit_tool.cpp.

1453{
1455 SCH_ITEM* head = static_cast<SCH_ITEM*>( selection.Front() );
1456 bool moving = head && head->IsMoving();
1457
1458 if( selection.Empty() )
1459 return 0;
1460
1461 std::vector<SCH_ITEM*> autoplaceItems;
1462
1463 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
1464 {
1465 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
1466
1467 if( item->IsType( EE_COLLECTOR::FieldOwners ) )
1468 autoplaceItems.push_back( item );
1469 else if( item->GetParent() && item->GetParent()->IsType( EE_COLLECTOR::FieldOwners ) )
1470 autoplaceItems.push_back( static_cast<SCH_ITEM*>( item->GetParent() ) );
1471 }
1472
1473 bool appendUndo = false;
1474
1475 for( SCH_ITEM* sch_item : autoplaceItems )
1476 {
1477 if( !moving && !sch_item->IsNew() )
1478 {
1479 saveCopyInUndoList( sch_item, UNDO_REDO::CHANGED, appendUndo, false );
1480 appendUndo = true;
1481 }
1482
1483 sch_item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1484
1485 updateItem( sch_item, true );
1486 }
1487
1489
1490 if( moving )
1491 {
1493 }
1494 else
1495 {
1496 if( selection.IsHover() )
1498
1499 m_frame->OnModify();
1500 }
1501
1502 return 0;
1503}
static TOOL_ACTION refreshPreview
Definition: actions.h:110
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
bool IsMoving() const
Definition: eda_item.h:104
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static const std::vector< KICAD_T > FieldOwners
Definition: ee_collectors.h:44
EE_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
Return either an existing selection (filtered), or the selection at the current cursor position if th...
void updateItem(EDA_ITEM *aItem, bool aUpdateRTree) const
Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the ...
Definition: ee_tool_base.h:103
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false, bool aDirtyConnectivity=true)
Definition: ee_tool_base.h:134
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:191
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static const std::vector< KICAD_T > RotatableItems
Definition: sch_edit_tool.h:42
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:162
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:75
bool IsHover() const
Definition: selection.h:83
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:99
EDA_ITEM * Front() const
Definition: selection.h:208
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142

References CHANGED, EE_ACTIONS::clearSelection, SELECTION::Empty(), EE_COLLECTOR::FieldOwners, SELECTION::Front(), SELECTION::GetItem(), EDA_ITEM::GetParent(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), EDA_ITEM::IsType(), SCH_ITEM::IsType(), 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_MANAGER::PostEvent(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), RotatableItems, TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), EVENTS::SelectedItemsModified, and EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem().

Referenced by setTransitions().

◆ BreakWire()

int SCH_EDIT_TOOL::BreakWire ( const TOOL_EVENT aEvent)

Definition at line 2210 of file sch_edit_tool.cpp.

2211{
2212 bool isSlice = aEvent.Matches( EE_ACTIONS::slice.MakeEvent() );
2215
2216 std::vector<SCH_LINE*> lines;
2217
2218 for( EDA_ITEM* item : selection )
2219 {
2220 if( SCH_LINE* line = dyn_cast<SCH_LINE*>( item ) )
2221 {
2222 if( !line->IsEndPoint( cursorPos ) )
2223 lines.push_back( line );
2224 }
2225 }
2226
2229
2230 for( SCH_LINE* line : lines )
2231 {
2232 SCH_LINE* newLine;
2233
2234 // We let the user select the break point if they're on a single line
2235 if( lines.size() == 1 && line->HitTest( cursorPos ) )
2236 m_frame->BreakSegment( line, cursorPos, &newLine );
2237 else
2238 m_frame->BreakSegment( line, line->GetMidPoint(), &newLine );
2239
2240 // Make sure both endpoints are deselected
2241 newLine->ClearFlags();
2242
2244 line->SetFlags( ENDPOINT );
2245
2246 // If we're a break, we want to drag both wires.
2247 // Side note: the drag/move tool only checks whether the first item is
2248 // new to determine if it should append undo or not, someday this should
2249 // be cleaned up and explictly controlled but for now the newLine
2250 // selection addition must be after the existing line.
2251 if( !isSlice )
2252 {
2253 m_selectionTool->AddItemToSel( newLine );
2254 newLine->SetFlags( STARTPOINT );
2255 }
2256 }
2257
2258 if( !lines.empty() )
2259 {
2261
2262 m_frame->OnModify();
2264
2265 m_toolMgr->RunAction( EE_ACTIONS::drag, false, true );
2266 }
2267
2268 return 0;
2269}
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
static TOOL_ACTION slice
Definition: ee_actions.h:144
static TOOL_ACTION drag
Definition: ee_actions.h:121
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void BreakSegment(SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
Break a single segment into two at the specified point.
void StartNewUndo()
Create a new, blank stack for future Undo commands to be pushed to.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
int AddItemToSel(const TOOL_EVENT &aEvent)
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool DisableGridSnapping() const
Definition: tool_event.h:344
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:365
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
@ SCH_LINE_T
Definition: typeinfo.h:146

References SELECTION_TOOL::AddItemToSel(), SCH_EDIT_FRAME::BreakSegment(), EDA_ITEM::ClearFlags(), EE_SELECTION_TOOL::ClearSelection(), TOOL_EVENT::DisableGridSnapping(), EE_ACTIONS::drag, ENDPOINT, SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), 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(), EDA_DRAW_PANEL_GAL::Refresh(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_LINE_T, EDA_ITEM::SetFlags(), EE_ACTIONS::slice, SCH_EDIT_FRAME::StartNewUndo(), STARTPOINT, and SCH_EDIT_FRAME::TestDanglingEnds().

Referenced by setTransitions().

◆ ChangeSymbols()

int SCH_EDIT_TOOL::ChangeSymbols ( const TOOL_EVENT aEvent)

Definition at line 1506 of file sch_edit_tool.cpp.

1507{
1508 SCH_SYMBOL* selectedSymbol = nullptr;
1510
1511 if( !selection.Empty() )
1512 selectedSymbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
1513
1515
1516 if( aEvent.IsAction( &EE_ACTIONS::changeSymbol )
1517 || aEvent.IsAction( &EE_ACTIONS::changeSymbols ) )
1518 {
1520 }
1521
1522 DIALOG_CHANGE_SYMBOLS dlg( m_frame, selectedSymbol, mode );
1523
1524 dlg.ShowQuasiModal();
1525
1526 return 0;
1527}
Dialog to update or change schematic library symbols.
static TOOL_ACTION changeSymbol
Definition: ee_actions.h:158
static TOOL_ACTION changeSymbols
Definition: ee_actions.h:156
Schematic symbol object.
Definition: sch_symbol.h:81
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:81
@ SCH_SYMBOL_T
Definition: typeinfo.h:156

References DIALOG_CHANGE_SYMBOLS::CHANGE, EE_ACTIONS::changeSymbol, EE_ACTIONS::changeSymbols, SELECTION::Empty(), SELECTION::Front(), TOOL_EVENT::IsAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, EE_SELECTION_TOOL::RequestSelection(), SCH_SYMBOL_T, DIALOG_SHIM::ShowQuasiModal(), and DIALOG_CHANGE_SYMBOLS::UPDATE.

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 1883 of file sch_edit_tool.cpp.

1884{
1885 KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
1887 SCH_TEXT_T,
1888 SCH_TEXTBOX_T } );
1889
1890 for( unsigned int i = 0; i < selection.GetSize(); ++i )
1891 {
1892 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( selection.GetItem( i ) );
1893
1894 if( item && item->Type() != convertTo )
1895 {
1896 bool selected = item->IsSelected();
1897 SCH_ITEM* newtext = nullptr;
1898 VECTOR2I position = item->GetPosition();
1899 wxString txt;
1900 wxString href;
1901 TEXT_SPIN_STYLE orientation = TEXT_SPIN_STYLE::SPIN::RIGHT;
1903
1904 switch( item->Type() )
1905 {
1906 case SCH_LABEL_T:
1907 case SCH_GLOBAL_LABEL_T:
1908 case SCH_HIER_LABEL_T:
1909 {
1910 SCH_TEXT* label = static_cast<SCH_LABEL_BASE*>( item );
1911
1912 txt = UnescapeString( label->GetText() );
1913 orientation = label->GetTextSpinStyle();
1914 shape = label->GetShape();
1915 href = label->GetHyperlink();
1916 break;
1917 }
1918
1920 {
1921 SCH_DIRECTIVE_LABEL* dirlabel = static_cast<SCH_DIRECTIVE_LABEL*>( item );
1922
1923 // a SCH_DIRECTIVE_LABEL has no text
1924 txt = _( "<empty>" );
1925
1926 orientation = dirlabel->GetTextSpinStyle();
1927 href = dirlabel->GetHyperlink();
1928 break;
1929 }
1930
1931 case SCH_TEXT_T:
1932 {
1933 SCH_TEXT* text = static_cast<SCH_TEXT*>( item );
1934
1935 txt = text->GetText();
1936 orientation = text->GetTextSpinStyle();
1937 href = text->GetHyperlink();
1938 break;
1939 }
1940
1941 case SCH_TEXTBOX_T:
1942 {
1943 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
1944 BOX2I bbox = textbox->GetBoundingBox();
1945
1946 bbox.Inflate( -textbox->GetTextMargin() );
1947
1948 if( convertTo == SCH_LABEL_T
1949 || convertTo == SCH_HIER_LABEL_T
1950 || convertTo == SCH_GLOBAL_LABEL_T )
1951 {
1952 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item );
1953 wxCHECK( text, 0 );
1954 int textSize = text->GetTextSize().y;
1955 bbox.Inflate( item->Schematic()->Settings().m_LabelSizeRatio * textSize );
1956 }
1957
1958 txt = textbox->GetText();
1959
1960 if( textbox->GetTextAngle().IsVertical() )
1961 {
1962 if( textbox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
1963 {
1964 orientation = TEXT_SPIN_STYLE::SPIN::BOTTOM;
1965 position = VECTOR2I( bbox.Centre().x, bbox.GetOrigin().y );
1966 }
1967 else
1968 {
1969 orientation = TEXT_SPIN_STYLE::SPIN::UP;
1970 position = VECTOR2I( bbox.Centre().x, bbox.GetEnd().y );
1971 }
1972 }
1973 else
1974 {
1975 if( textbox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
1976 {
1977 orientation = TEXT_SPIN_STYLE::SPIN::LEFT;
1978 position = VECTOR2I( bbox.GetEnd().x, bbox.Centre().y );
1979 }
1980 else
1981 {
1982 orientation = TEXT_SPIN_STYLE::SPIN::RIGHT;
1983 position = VECTOR2I( bbox.GetOrigin().x, bbox.Centre().y );
1984 }
1985 }
1986
1987 position = m_frame->GetNearestGridPosition( position );
1988 href = textbox->GetHyperlink();
1989 break;
1990 }
1991
1992 default:
1993 UNIMPLEMENTED_FOR( item->GetClass() );
1994 break;
1995 }
1996
1997 auto getValidNetname =
1998 []( const wxString& aText )
1999 {
2000 wxString local_txt = aText;
2001 local_txt.Replace( "\n", "_" );
2002 local_txt.Replace( "\r", "_" );
2003 local_txt.Replace( "\t", "_" );
2004
2005 // Bus groups can have spaces; bus vectors and signal names cannot
2006 if( !NET_SETTINGS::ParseBusGroup( aText, nullptr, nullptr ) )
2007 local_txt.Replace( " ", "_" );
2008
2009 // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
2010 local_txt = EscapeString( local_txt, CTX_NETNAME );
2011
2012 if( local_txt.IsEmpty() )
2013 return _( "<empty>" );
2014 else
2015 return local_txt;
2016 };
2017
2018 switch( convertTo )
2019 {
2020 case SCH_LABEL_T:
2021 {
2022 SCH_LABEL_BASE* new_label = new SCH_LABEL( position, getValidNetname( txt ) );
2023
2024 new_label->SetShape( shape );
2025 new_label->SetTextSpinStyle( orientation );
2026 new_label->SetHyperlink( href );
2027 newtext = new_label;
2028 break;
2029 }
2030
2031 case SCH_GLOBAL_LABEL_T:
2032 {
2033 SCH_LABEL_BASE* new_label = new SCH_GLOBALLABEL( position, getValidNetname( txt ) );
2034
2035 new_label->SetShape( shape );
2036 new_label->SetTextSpinStyle( orientation );
2037 new_label->SetHyperlink( href );
2038 newtext = new_label;
2039 break;
2040 }
2041
2042 case SCH_HIER_LABEL_T:
2043 {
2044 SCH_LABEL_BASE* new_label = new SCH_HIERLABEL( position, getValidNetname( txt ) );
2045
2046 new_label->SetShape( shape );
2047 new_label->SetTextSpinStyle( orientation );
2048 new_label->SetHyperlink( href );
2049 newtext = new_label;
2050 break;
2051 }
2052
2054 {
2055 SCH_LABEL_BASE* new_label = new SCH_DIRECTIVE_LABEL( position );
2056
2057 // A SCH_DIRECTIVE_LABEL usually has at least one field containing the net class
2058 // name. If we're copying from a text object assume the text is the netclass
2059 // name. Otherwise, we'll just copy the fields which will either have a netclass
2060 // or not.
2061 if( !dynamic_cast<SCH_LABEL_BASE*>( item ) )
2062 {
2063 SCH_FIELD netclass( position, 0, new_label, wxT( "Netclass" ) );
2064 netclass.SetText( txt );
2065 netclass.SetVisible( true );
2066 new_label->GetFields().push_back( netclass );
2067 }
2068
2069 new_label->SetShape( LABEL_FLAG_SHAPE::F_ROUND );
2070 new_label->SetTextSpinStyle( orientation );
2071 new_label->SetHyperlink( href );
2072 newtext = new_label;
2073 break;
2074 }
2075
2076 case SCH_TEXT_T:
2077 {
2078 SCH_TEXT* new_text = new SCH_TEXT( position, txt );
2079
2080 new_text->SetTextSpinStyle( orientation );
2081 new_text->SetHyperlink( href );
2082 newtext = new_text;
2083 break;
2084 }
2085
2086 case SCH_TEXTBOX_T:
2087 {
2088 SCH_TEXTBOX* new_textbox = new SCH_TEXTBOX( 0, FILL_T::NO_FILL, txt );
2089 BOX2I bbox = item->GetBoundingBox();
2090
2091 if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )
2092 bbox.Inflate( -label->GetLabelBoxExpansion() );
2093
2094 EDA_TEXT* textItem = dynamic_cast<EDA_TEXT*>( item );
2095 wxCHECK(textItem, 0 );
2096
2097 // Careful: GetTextMargin() is dependent on font size...
2098 new_textbox->SetTextSize( textItem->GetTextSize() );
2099
2100 int margin = new_textbox->GetTextMargin();
2101 bbox.Inflate( margin );
2102
2103 // Add 1/20 of the margin at the end to reduce line-breaking changes.
2104 int slop = margin / 20;
2105
2106 switch( orientation )
2107 {
2108 case TEXT_SPIN_STYLE::SPIN::RIGHT:
2109 new_textbox->SetPosition( bbox.GetPosition() );
2110 new_textbox->SetEnd( bbox.GetEnd() + VECTOR2I( slop, 0 ) );
2111 break;
2112
2113 case TEXT_SPIN_STYLE::SPIN::LEFT:
2114 new_textbox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
2115 new_textbox->SetPosition( bbox.GetPosition() - VECTOR2I( slop, 0 ) );
2116 new_textbox->SetEnd( bbox.GetEnd() );
2117 break;
2118
2119 case TEXT_SPIN_STYLE::SPIN::UP:
2120 new_textbox->SetTextAngle( ANGLE_VERTICAL );
2121 new_textbox->SetPosition( bbox.GetPosition() - VECTOR2I( 0, slop ) );
2122 new_textbox->SetEnd( bbox.GetEnd() );
2123 break;
2124
2125 case TEXT_SPIN_STYLE::SPIN::BOTTOM:
2126 new_textbox->SetTextAngle( ANGLE_VERTICAL );
2127 new_textbox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
2128 new_textbox->SetPosition( bbox.GetPosition() );
2129 new_textbox->SetEnd( bbox.GetEnd() + VECTOR2I( 0, slop ) );
2130 break;
2131 }
2132
2133 new_textbox->SetHyperlink( href );
2134 newtext = new_textbox;
2135 break;
2136 }
2137
2138 default:
2139 UNIMPLEMENTED_FOR( wxString::Format( "%d.", convertTo ) );
2140 break;
2141 }
2142
2143 wxCHECK2( newtext, continue );
2144
2145 // Copy the old text item settings to the new one. Justifications are not copied
2146 // because they are not used in labels. Justifications will be set to default value
2147 // in the new text item type.
2148 //
2149 newtext->SetFlags( item->GetEditFlags() );
2150
2151 EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( item );
2152 EDA_TEXT* new_eda_text = dynamic_cast<EDA_TEXT*>( newtext );
2153
2154 wxCHECK2( eda_text && new_eda_text, continue );
2155
2156 new_eda_text->SetFont( eda_text->GetFont() );
2157 new_eda_text->SetTextSize( eda_text->GetTextSize() );
2158 new_eda_text->SetTextThickness( eda_text->GetTextThickness() );
2159 new_eda_text->SetItalic( eda_text->IsItalic() );
2160 new_eda_text->SetBold( eda_text->IsBold() );
2161
2162 newtext->AutoplaceFields( m_frame->GetScreen(), false );
2163
2164 SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item );
2165 SCH_LABEL_BASE* new_label = dynamic_cast<SCH_LABEL_BASE*>( newtext );
2166
2167 if( label && new_label )
2168 new_label->SetFields( label->GetFields() );
2169
2170 if( selected )
2172
2173 if( !item->IsNew() )
2174 {
2175 saveCopyInUndoList( item, UNDO_REDO::DELETED, i != 0 );
2176 saveCopyInUndoList( newtext, UNDO_REDO::NEWITEM, true );
2177
2179 m_frame->AddToScreen( newtext, m_frame->GetScreen() );
2180 }
2181
2182 if( selected )
2183 m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
2184
2185 // Otherwise, pointer is owned by the undo stack
2186 if( item->IsNew() )
2187 delete item;
2188
2189 if( convertTo == SCH_TEXT_T || convertTo == SCH_TEXTBOX_T )
2190 {
2191 if( newtext->IsDangling() )
2192 getView()->Update( newtext, KIGFX::REPAINT );
2193 }
2194 else
2195 {
2197 }
2198
2199 m_frame->OnModify();
2200 }
2201 }
2202
2203 if( selection.IsHover() )
2205
2206 return 0;
2207}
const Vec & GetPosition() const
Definition: box2.h:184
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
Vec Centre() const
Definition: box2.h:70
bool IsVertical() const
Definition: eda_angle.h:179
VECTOR2I GetNearestGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize location to aPosition.
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:145
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsSelected() const
Definition: eda_item.h:106
bool IsNew() const
Definition: eda_item.h:103
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:149
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
wxString GetHyperlink() const
Definition: eda_text.h:334
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:187
void SetBold(bool aBold)
Definition: eda_text.cpp:211
bool IsBold() const
Definition: eda_text.h:133
void SetHyperlink(wxString aLink)
Definition: eda_text.h:335
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:349
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:195
int GetTextThickness() const
Definition: eda_text.h:112
void SetItalic(bool aItalic)
Definition: eda_text.cpp:203
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:333
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:242
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:60
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1591
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
virtual wxString GetClass() const override
Return the class name.
Definition: sch_item.h:157
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
virtual bool IsDangling() const
Definition: sch_item.h:342
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:442
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition: sch_label.h:98
void SetShape(LABEL_FLAG_SHAPE aShape) override
Definition: sch_label.h:74
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:90
void SetPosition(const VECTOR2I &aPos) override
Definition: sch_shape.h:78
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.h:75
int GetTextMargin() const
Definition: sch_textbox.cpp:64
TEXT_SPIN_STYLE GetTextSpinStyle() const
Definition: sch_text.h:148
virtual LABEL_FLAG_SHAPE GetShape() const
Definition: sch_text.h:150
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:188
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
#define _(s)
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:426
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
LABEL_FLAG_SHAPE
Definition: sch_text.h:96
@ L_UNSPECIFIED
Definition: sch_text.h:101
@ F_ROUND
Definition: sch_text.h:105
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_NETNAME
Definition: string_utils.h:54
@ GR_TEXT_H_ALIGN_RIGHT
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:154
@ SCH_LABEL_T
Definition: typeinfo.h:151
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:175
@ SCH_TEXT_T
Definition: typeinfo.h:150
@ SCH_TEXTBOX_T
Definition: typeinfo.h:149
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References _, EE_ACTIONS::addItemToSel, SCH_BASE_FRAME::AddToScreen(), ANGLE_VERTICAL, SCH_ITEM::AutoplaceFields(), BOX2< Vec >::Centre(), EE_ACTIONS::clearSelection, CTX_NETNAME, DELETED, EscapeString(), F_ROUND, Format(), EDA_ITEM::GetBoundingBox(), SCH_SHAPE::GetBoundingBox(), SCH_ITEM::GetClass(), EDA_ITEM::GetEditFlags(), BOX2< Vec >::GetEnd(), SCH_LABEL_BASE::GetFields(), EDA_TEXT::GetFont(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetHyperlink(), EDA_DRAW_FRAME::GetNearestGridPosition(), BOX2< Vec >::GetOrigin(), EDA_ITEM::GetPosition(), BOX2< Vec >::GetPosition(), SCH_EDIT_FRAME::GetScreen(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), SCH_TEXTBOX::GetTextMargin(), EDA_TEXT::GetTextSize(), SCH_TEXT::GetTextSpinStyle(), EDA_TEXT::GetTextThickness(), TOOL_BASE::getView(), GR_TEXT_H_ALIGN_RIGHT, BOX2< Vec >::Inflate(), EDA_TEXT::IsBold(), SCH_ITEM::IsDangling(), EDA_TEXT::IsItalic(), EDA_ITEM::IsNew(), EDA_ITEM::IsSelected(), EDA_ANGLE::IsVertical(), L_UNSPECIFIED, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCHEMATIC_SETTINGS::m_LabelSizeRatio, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, NEWITEM, NO_FILL, SCH_EDIT_FRAME::OnModify(), TOOL_EVENT::Parameter(), NET_SETTINGS::ParseBusGroup(), SCH_BASE_FRAME::RemoveFromScreen(), EE_ACTIONS::removeItemFromSel, KIGFX::REPAINT, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_LOCATE_ANY_T, SCH_LABEL_T, SCH_TEXT_T, SCH_TEXTBOX_T, SCH_ITEM::Schematic(), EDA_TEXT::SetBold(), EDA_SHAPE::SetEnd(), SCH_LABEL_BASE::SetFields(), EDA_ITEM::SetFlags(), EDA_TEXT::SetFont(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetHyperlink(), EDA_TEXT::SetItalic(), SCH_SHAPE::SetPosition(), SCH_LABEL_BASE::SetShape(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextSize(), SCH_TEXT::SetTextSpinStyle(), EDA_TEXT::SetTextThickness(), SCHEMATIC::Settings(), EDA_TEXT::SetVisible(), SCH_EDIT_FRAME::TestDanglingEnds(), text, EDA_ITEM::Type(), UnescapeString(), UNIMPLEMENTED_FOR, KIGFX::VIEW::Update(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ CleanupSheetPins()

int SCH_EDIT_TOOL::CleanupSheetPins ( const TOOL_EVENT aEvent)

Definition at line 2272 of file sch_edit_tool.cpp.

2273{
2275 SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
2276
2277 if( !sheet || !sheet->HasUndefinedPins() )
2278 return 0;
2279
2280 if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
2281 return 0;
2282
2284
2285 sheet->CleanupSheet();
2286
2287 updateItem( sheet, true );
2288 m_frame->OnModify();
2289
2290 if( selection.IsHover() )
2292
2293 return 0;
2294}
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:556
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:442
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:380
@ SCH_SHEET_T
Definition: typeinfo.h:158

References _, CHANGED, SCH_SHEET::CleanupSheet(), EE_ACTIONS::clearSelection, SELECTION::Front(), 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(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_SHEET_T, and EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem().

Referenced by setTransitions().

◆ ConvertDeMorgan()

int SCH_EDIT_TOOL::ConvertDeMorgan ( const TOOL_EVENT aEvent)

Definition at line 1530 of file sch_edit_tool.cpp.

1531{
1533
1534 if( selection.Empty() )
1535 return 0;
1536
1537 SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
1538
1540 && symbol->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
1541 {
1542 return 0;
1543 }
1544
1546 && symbol->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
1547 {
1548 return 0;
1549 }
1550
1551 if( !symbol->IsNew() )
1553
1554 m_frame->ConvertPart( symbol );
1555
1556 if( symbol->IsNew() )
1558
1559 if( selection.IsHover() )
1561
1562 return 0;
1563}
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:135
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:134
void ConvertPart(SCH_SYMBOL *aSymbol)
Definition: picksymbol.cpp:280
int GetConvert() const
Definition: sch_symbol.h:270

References CHANGED, EE_ACTIONS::clearSelection, SCH_EDIT_FRAME::ConvertPart(), SELECTION::Empty(), SELECTION::Front(), SCH_SYMBOL::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(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_SYMBOL_T, EE_ACTIONS::showDeMorganAlternate, and EE_ACTIONS::showDeMorganStandard.

Referenced by setTransitions().

◆ DdAppendFile()

int SCH_EDIT_TOOL::DdAppendFile ( const TOOL_EVENT aEvent)

Drag and drop.

Definition at line 2366 of file sch_edit_tool.cpp.

2367{
2368 wxString aFileName = *aEvent.Parameter<wxString*>();
2369 return ( m_frame->AddSheetAndUpdateDisplay( aFileName ) ? 0 : 1 );
2370}
bool AddSheetAndUpdateDisplay(const wxString aFullFileName)
Add a sheet file into the current sheet and updates display.

References SCH_EDIT_FRAME::AddSheetAndUpdateDisplay(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and TOOL_EVENT::Parameter().

Referenced by setTransitions().

◆ DeleteItemCursor()

int SCH_EDIT_TOOL::DeleteItemCursor ( const TOOL_EVENT aEvent)

Definition at line 1294 of file sch_edit_tool.cpp.

1295{
1297
1299 m_pickerItem = nullptr;
1300
1301 // Deactivate other tools; particularly important if another PICKER is currently running
1302 Activate();
1303
1304 picker->SetCursor( KICURSOR::REMOVE );
1305 picker->SetSnapping( false );
1306
1307 picker->SetClickHandler(
1308 [this]( const VECTOR2D& aPosition ) -> bool
1309 {
1310 if( m_pickerItem )
1311 {
1313 selectionTool->UnbrightenItem( m_pickerItem );
1314 selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
1316 m_pickerItem = nullptr;
1317 }
1318
1319 return true;
1320 } );
1321
1322 picker->SetMotionHandler(
1323 [this]( const VECTOR2D& aPos )
1324 {
1325 EE_COLLECTOR collector;
1326 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1327 collector.Collect( m_frame->GetScreen(), deletableItems, aPos );
1328
1330 selectionTool->GuessSelectionCandidates( collector, aPos );
1331
1332 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
1333
1334 if( m_pickerItem != item )
1335 {
1336 if( m_pickerItem )
1337 selectionTool->UnbrightenItem( m_pickerItem );
1338
1339 m_pickerItem = item;
1340
1341 if( m_pickerItem )
1342 selectionTool->BrightenItem( m_pickerItem );
1343 }
1344 } );
1345
1346 picker->SetFinalizeHandler(
1347 [this]( const int& aFinalState )
1348 {
1349 if( m_pickerItem )
1350 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
1351
1352 // Wake the selection tool after exiting to ensure the cursor gets updated
1354 } );
1355
1357
1358 return 0;
1359}
static TOOL_ACTION pickerTool
Definition: actions.h:159
static TOOL_ACTION doDelete
Definition: actions.h:73
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
int m_Threshold
Definition: collector.h:234
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
void Collect(SCH_SCREEN *aScreen, const std::vector< KICAD_T > &aScanTypes, const VECTOR2I &aPos, int aUnit=0, int aConvert=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:82
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
void SetSnapping(bool aSnap)
Definition: picker_tool.h:64
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:102
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
void Activate()
Run the tool.
#define HITTEST_THRESHOLD_PIXELS
static std::vector< KICAD_T > deletableItems
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:85

References TOOL_INTERACTIVE::Activate(), SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::BrightenItem(), EE_ACTIONS::clearSelection, EE_COLLECTOR::Collect(), deletableItems, ACTIONS::doDelete, COLLECTOR::GetCount(), SCH_EDIT_FRAME::GetScreen(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), EE_SELECTION_TOOL::GuessSelectionCandidates(), HITTEST_THRESHOLD_PIXELS, KiROUND(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_pickerItem, COLLECTOR::m_Threshold, TOOL_BASE::m_toolMgr, ACTIONS::pickerTool, REMOVE, TOOL_MANAGER::RunAction(), EE_ACTIONS::selectionActivate, PICKER_TOOL_BASE::SetClickHandler(), PICKER_TOOL_BASE::SetCursor(), PICKER_TOOL_BASE::SetFinalizeHandler(), PICKER_TOOL_BASE::SetMotionHandler(), PICKER_TOOL_BASE::SetSnapping(), and SELECTION_TOOL::UnbrightenItem().

Referenced by setTransitions().

◆ DoDelete()

int SCH_EDIT_TOOL::DoDelete ( const TOOL_EVENT aEvent)

Run the deletion tool.

Definition at line 1198 of file sch_edit_tool.cpp.

1199{
1200 SCH_SCREEN* screen = m_frame->GetScreen();
1202 bool appendToUndo = false;
1203 std::vector<VECTOR2I> pts;
1204
1205 if( items.empty() )
1206 return 0;
1207
1208 // Don't leave a freed pointer in the selection
1210
1211 for( EDA_ITEM* item : items )
1212 item->ClearFlags( STRUCT_DELETED );
1213
1214 for( EDA_ITEM* item : items )
1215 {
1216 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
1217
1218 if( !sch_item )
1219 continue;
1220
1221 if( sch_item->IsConnectable() )
1222 {
1223 std::vector<VECTOR2I> tmp_pts = sch_item->GetConnectionPoints();
1224 pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
1225 }
1226
1227 if( sch_item->Type() == SCH_JUNCTION_T )
1228 {
1229 sch_item->SetFlags( STRUCT_DELETED );
1230 // clean up junctions at the end
1231 }
1232 else if( sch_item->Type() == SCH_SHEET_PIN_T )
1233 {
1234 SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
1235 SCH_SHEET* sheet = pin->GetParent();
1236
1237 if( !alg::contains( items, sheet ) )
1238 {
1239 pin->SetFlags( STRUCT_DELETED );
1240 saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
1241 appendToUndo = true;
1242
1243 updateItem( pin, false );
1244
1245 sheet->RemovePin( pin );
1246 }
1247 }
1248 else if( sch_item->Type() == SCH_FIELD_T )
1249 {
1250 saveCopyInUndoList( item, UNDO_REDO::CHANGED, appendToUndo );
1251 static_cast<SCH_FIELD*>( sch_item )->SetVisible( false );
1252 appendToUndo = true;
1253
1254 updateItem( sch_item, false );
1255 }
1256 else
1257 {
1258 sch_item->SetFlags( STRUCT_DELETED );
1259 saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
1260 appendToUndo = true;
1261
1262 updateItem( sch_item, false );
1263
1264 m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() );
1265
1266 if( sch_item->Type() == SCH_SHEET_T )
1268 }
1269 }
1270
1271 for( const VECTOR2I& point : pts )
1272 {
1273 SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
1274
1275 if( !junction )
1276 continue;
1277
1278 if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsExplicitJunction( point ) )
1279 m_frame->DeleteJunction( junction, appendToUndo );
1280 }
1281
1283
1285 m_frame->OnModify();
1286
1287 return 0;
1288}
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:143
void DeleteJunction(SCH_ITEM *aItem, bool aAppend=false)
Removes a given junction and heals any wire segments under the junction.
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
virtual bool IsConnectable() const
Definition: sch_item.h:349
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:364
bool IsExplicitJunction(const VECTOR2I &aPosition) const
Indicates that a junction dot is necessary at the given location.
Definition: sch_screen.cpp:468
SCH_ITEM * GetItem(const VECTOR2I &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:376
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:380
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:120
#define STRUCT_DELETED
flag indication structures to be erased
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_JUNCTION_T
Definition: typeinfo.h:142

References CHANGED, EE_ACTIONS::clearSelection, alg::contains(), deletableItems, DELETED, SCH_EDIT_FRAME::DeleteJunction(), SCH_BASE_FRAME::GetCanvas(), SCH_ITEM::GetConnectionPoints(), SCH_SCREEN::GetItem(), SELECTION::GetItems(), SCH_EDIT_FRAME::GetScreen(), EDA_ITEM::HasFlag(), SCH_ITEM::IsConnectable(), SCH_SCREEN::IsExplicitJunction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), pin, 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_FIELD_T, 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(), and EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem().

Referenced by setTransitions().

◆ EditField()

int SCH_EDIT_TOOL::EditField ( const TOOL_EVENT aEvent)

Definition at line 1407 of file sch_edit_tool.cpp.

1408{
1409 EE_SELECTION sel;
1410
1411 if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1413 else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1415 else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1417
1418 if( sel.Size() != 1 )
1419 return 0;
1420
1421 bool clearSelection = sel.IsHover();
1422 EDA_ITEM* item = sel.Front();
1423
1424 if( item->Type() == SCH_SYMBOL_T )
1425 {
1426 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1427
1428 if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1430 else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1431 editFieldText( symbol->GetField( VALUE_FIELD ) );
1432 else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1434 }
1435 else if( item->Type() == SCH_FIELD_T )
1436 {
1437 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
1438
1439 editFieldText( field );
1440
1441 if( !field->IsVisible() )
1442 clearSelection = true;
1443 }
1444
1445 if( clearSelection )
1447
1448 return 0;
1449}
virtual bool IsVisible() const
Definition: eda_text.h:136
static TOOL_ACTION editValue
Definition: ee_actions.h:130
static TOOL_ACTION editFootprint
Definition: ee_actions.h:131
static TOOL_ACTION editReference
Definition: ee_actions.h:129
void editFieldText(SCH_FIELD *aField)
Set up handlers for various events.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:865
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ SCH_FIELD_LOCATE_REFERENCE_T
Definition: typeinfo.h:164
@ SCH_FIELD_LOCATE_FOOTPRINT_T
Definition: typeinfo.h:166
@ SCH_FIELD_LOCATE_VALUE_T
Definition: typeinfo.h:165

References EE_ACTIONS::clearSelection, editFieldText(), EE_ACTIONS::editFootprint, EE_ACTIONS::editReference, EE_ACTIONS::editValue, FOOTPRINT_FIELD, SELECTION::Front(), SCH_SYMBOL::GetField(), TOOL_EVENT::IsAction(), SELECTION::IsHover(), EDA_TEXT::IsVisible(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, REFERENCE_FIELD, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_FIELD_LOCATE_REFERENCE_T, SCH_FIELD_LOCATE_VALUE_T, SCH_FIELD_T, SCH_SYMBOL_T, SELECTION::Size(), EDA_ITEM::Type(), and VALUE_FIELD.

Referenced by setTransitions().

◆ editFieldText()

void SCH_EDIT_TOOL::editFieldText ( SCH_FIELD aField)
private

Set up handlers for various events.

Definition at line 1362 of file sch_edit_tool.cpp.

1363{
1364 KICAD_T parentType = aField->GetParent() ? aField->GetParent()->Type() : SCHEMATIC_T;
1365
1366 // Save old symbol in undo list if not already in edit, or moving.
1367 if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
1369
1370 if( parentType == SCH_SYMBOL_T && aField->GetId() == REFERENCE_FIELD )
1371 static_cast<SCH_ITEM*>( aField->GetParent() )->SetConnectivityDirty();
1372
1373 wxString caption;
1374
1375 // Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
1376 if( parentType == SCH_SYMBOL_T && aField->GetId() < MANDATORY_FIELDS )
1377 {
1378 wxString translated_fieldname;
1379 translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(),
1380 DO_TRANSLATE );
1381 caption.Printf( _( "Edit %s Field" ), TitleCaps( translated_fieldname ) );
1382 }
1383 else if( parentType == SCH_SHEET_T && aField->GetId() < SHEET_MANDATORY_FIELDS )
1384 caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
1385 else
1386 caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
1387
1388 DIALOG_SCH_FIELD_PROPERTIES dlg( m_frame, caption, aField );
1389
1390 // The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
1391 if( dlg.ShowQuasiModal() != wxID_OK )
1392 return;
1393
1394 dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
1395
1396 if( m_frame->eeconfig()->m_AutoplaceFields.enable || parentType == SCH_SHEET_T )
1397 static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
1398
1399 m_frame->UpdateItem( aField, false, true );
1400 m_frame->OnModify();
1401
1402 // This must go after OnModify() so that the connectivity graph will have been updated.
1404}
Handle editing a single symbol field in the schematic editor.
AUTOPLACE_FIELDS m_AutoplaceFields
EESCHEMA_SETTINGS * eeconfig() const
SCH_SHEET_PATH & GetCurrentSheet() const
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
int GetId() const
Definition: sch_field.h:125
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:804
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:49
wxString TitleCaps(const wxString &aString)
Capitalize the first letter in each word.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
#define DO_TRANSLATE
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ SCHEMATIC_T
Definition: typeinfo.h:188

References _, CHANGED, DO_TRANSLATE, SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, SCH_EDIT_FRAME::GetCurrentSheet(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), EDA_ITEM::GetEditFlags(), SCH_FIELD::GetId(), 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, MANDATORY_FIELDS, SCH_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), REFERENCE_FIELD, EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_SHEET_T, SCH_SYMBOL_T, SCHEMATIC_T, EVENTS::SelectedItemsModified, SHEET_MANDATORY_FIELDS, DIALOG_SHIM::ShowQuasiModal(), TitleCaps(), EDA_ITEM::Type(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), and SCH_EDIT_FRAME::UpdateItem().

Referenced by EditField(), and Properties().

◆ EditPageNumber()

int SCH_EDIT_TOOL::EditPageNumber ( const TOOL_EVENT aEvent)

Definition at line 2297 of file sch_edit_tool.cpp.

2298{
2300
2301 if( selection.GetSize() > 1 )
2302 return 0;
2303
2304 SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
2305
2307
2308 SCH_SCREEN* screen;
2309
2310 if( sheet )
2311 {
2312 // When changing the page number of a selected sheet, the current screen owns the sheet.
2313 screen = m_frame->GetScreen();
2314
2315 instance.push_back( sheet );
2316 }
2317 else
2318 {
2319 SCH_SHEET_PATH prevInstance = instance;
2320
2321 // When change the page number in the screen, the previous screen owns the sheet.
2322 if( prevInstance.size() )
2323 {
2324 prevInstance.pop_back();
2325 screen = prevInstance.LastScreen();
2326 }
2327 else
2328 {
2329 // The root sheet and root screen are effectively the same thing.
2330 screen = m_frame->GetScreen();
2331 }
2332
2333 sheet = m_frame->GetCurrentSheet().Last();
2334 }
2335
2336 wxString msg;
2337 wxString sheetPath = instance.PathHumanReadable( false );
2338 wxString pageNumber = instance.GetPageNumber();
2339
2340 msg.Printf( _( "Enter page number for sheet path%s" ),
2341 ( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath );
2342
2343 wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
2344
2345 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
2346
2347 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue() == instance.GetPageNumber() )
2348 return 0;
2349
2350 m_frame->SaveCopyInUndoList( screen, sheet, UNDO_REDO::CHANGED, false );
2351
2352 instance.SetPageNumber( dlg.GetValue() );
2353
2354 if( instance == m_frame->GetCurrentSheet() )
2355 {
2356 m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
2358 }
2359
2360 m_frame->OnModify();
2361
2362 return 0;
2363}
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
void OnPageSettingsChange() override
Called when modifying the page settings.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.

References _, CHANGED, SELECTION::Front(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET_PATH::GetPageNumber(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), SCH_SHEET_PATH::Last(), SCH_SHEET_PATH::LastScreen(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, SCH_EDIT_FRAME::OnModify(), SCH_EDIT_FRAME::OnPageSettingsChange(), SCH_SHEET_PATH::PathHumanReadable(), SCH_SHEET_PATH::pop_back(), SCH_SHEET_PATH::push_back(), EE_SELECTION_TOOL::RequestSelection(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SHEET_T, SCH_SHEET_PATH::SetPageNumber(), BASE_SCREEN::SetPageNumber(), and SCH_SHEET_PATH::size().

Referenced by setTransitions().

◆ getEditFrame()

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

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

Definition at line 185 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), and ZONE_CREATE_HELPER::setUniquePriority().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122 {
123 return m_toolId;
124 }

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

◆ getModel()

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

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 197 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ getModelInt()

EDA_ITEM * TOOL_BASE::getModelInt ( ) const
privateinherited

Definition at line 54 of file tool_base.cpp.

55{
56 return m_toolMgr->GetModel();
57}
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292

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

Referenced by TOOL_BASE::getModel().

◆ GetName()

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

Return the name of the tool.

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

Returns
The name of the tool.

Definition at line 134 of file tool_base.h.

135 {
136 return m_toolName;
137 }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

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

◆ getToolHolderInt()

TOOLS_HOLDER * TOOL_BASE::getToolHolderInt ( ) const
privateinherited

Definition at line 48 of file tool_base.cpp.

49{
50 return m_toolMgr->GetToolHolder();
51}
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296

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

Referenced by TOOL_BASE::getEditFrame().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 109 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

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

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), ROUTER_TOOL::handleCommonEvents(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), PCB_SELECTION_TOOL::hitTestDistance(), Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), Properties(), EDIT_TOOL::Properties(), EE_SELECTION_TOOL::Reset(), EE_TOOL_BASE< T >::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PNS::TOOL_BASE::Reset(), BOARD_EDITOR_CONTROL::Reset(), DRAWING_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Reset(), Rotate(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_EDITOR_CONTROL::ToggleOPCurrents(), SCH_EDITOR_CONTROL::ToggleOPVoltages(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), PL_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_FIND_REPLACE_TOOL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< T >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_SELECTION_TOOL::view(), PCB_TOOL_BASE::view(), PCB_VIEWER_TOOLS::view(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

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

Return the instance of VIEW_CONTROLS object used in the application.

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

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

◆ GlobalEdit()

int SCH_EDIT_TOOL::GlobalEdit ( const TOOL_EVENT aEvent)

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

Definition at line 586 of file eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp.

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame.

Referenced by setTransitions().

◆ Go()

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

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

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

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

◆ goInternal()

void TOOL_INTERACTIVE::goInternal ( TOOL_STATE_FUNC aState,
const TOOL_EVENT_LIST aConditions 
)
privateinherited

Definition at line 70 of file tool_interactive.cpp.

71{
72 m_toolMgr->ScheduleNextState( this, aState, aConditions );
73}
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.

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

Referenced by TOOL_INTERACTIVE::Go().

◆ Init()

bool SCH_EDIT_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

Definition at line 140 of file sch_edit_tool.cpp.

141{
143
146
147 wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
148
149 auto hasElements =
150 [this]( const SELECTION& aSel )
151 {
152 return !m_frame->GetScreen()->Items().empty();
153 };
154
155 auto sheetHasUndefinedPins =
156 []( const SELECTION& aSel )
157 {
158 if( aSel.Size() == 1 && aSel.Front()->Type() == SCH_SHEET_T )
159 return static_cast<SCH_SHEET*>( aSel.Front() )->HasUndefinedPins();
160
161 return false;
162 };
163
164 auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
165
166 auto haveHighlight =
167 [&]( const SELECTION& sel )
168 {
169 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
170
171 return editFrame && editFrame->GetHighlightedConnection() != nullptr;
172 };
173
174 auto anyTextTool =
175 [this]( const SELECTION& aSel )
176 {
182 };
183
184 auto duplicateCondition =
185 []( const SELECTION& aSel )
186 {
188 return false;
189
190 return true;
191 };
192
193 auto orientCondition =
194 []( const SELECTION& aSel )
195 {
197 return false;
198
200 };
201
202 auto propertiesCondition =
203 [&]( const SELECTION& aSel )
204 {
205 if( aSel.GetSize() == 0 )
206 {
208 {
211
212 if( ds && ds->HitTestDrawingSheetItems( getView(), cursor ) )
213 return true;
214 }
215
216 return false;
217 }
218
219 SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
220 const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
221
222 if( !firstItem || !eeSelection )
223 return false;
224
225 switch( firstItem->Type() )
226 {
227 case SCH_SYMBOL_T:
228 case SCH_SHEET_T:
229 case SCH_SHEET_PIN_T:
230 case SCH_TEXT_T:
231 case SCH_TEXTBOX_T:
232 case SCH_LABEL_T:
234 case SCH_HIER_LABEL_T:
236 case SCH_FIELD_T:
237 case SCH_SHAPE_T:
238 case SCH_BITMAP_T:
239 return aSel.GetSize() == 1;
240
241 case SCH_LINE_T:
243 case SCH_JUNCTION_T:
244 if( std::all_of( aSel.Items().begin(), aSel.Items().end(),
245 [&]( const EDA_ITEM* item )
246 {
247 return item->Type() == SCH_LINE_T
248 && static_cast<const SCH_LINE*>( item )->IsGraphicLine();
249 } ) )
250 {
251 return true;
252 }
253 else if( std::all_of( aSel.Items().begin(), aSel.Items().end(),
254 [&]( const EDA_ITEM* item )
255 {
256 return item->Type() == SCH_JUNCTION_T;
257 } ) )
258 {
259 return true;
260 }
261 else if( std::all_of( aSel.Items().begin(), aSel.Items().end(),
262 [&]( const EDA_ITEM* item )
263 {
264 const SCH_ITEM* schItem = dynamic_cast<const SCH_ITEM*>( item );
265
266 wxCHECK( schItem, false );
267
268 return ( schItem->HasLineStroke() && schItem->IsConnectable() )
269 || item->Type() == SCH_JUNCTION_T;
270 } ) )
271 {
272 return true;
273 }
274
275 return false;
276
277 default:
278 return false;
279 }
280 };
281
282 auto autoplaceCondition =
283 []( const SELECTION& aSel )
284 {
285 for( const EDA_ITEM* item : aSel )
286 {
287 if( item->IsType( EE_COLLECTOR::FieldOwners ) )
288 return true;
289 }
290
291 return false;
292 };
293
294 // allTextTypes does not include SCH_SHEET_PIN_T because one cannot convert other
295 // types to/from this type, living only in a SHEET
296 static std::vector<KICAD_T> allTextTypes = { SCH_LABEL_T,
302
303 auto toChangeCondition = ( E_C::OnlyTypes( allTextTypes ) );
304
305 auto toLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_DIRECTIVE_LABEL_T,
309 SCH_TEXTBOX_T } ) )
310 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
311
312 auto toCLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
316 SCH_TEXTBOX_T } ) )
317 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
318
319 auto toHLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
323 SCH_TEXTBOX_T } ) )
324 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
325
326 auto toGLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
330 SCH_TEXTBOX_T } ) )
331 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
332
333 auto toTextCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
337 SCH_TEXTBOX_T } ) )
338 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
339
340 auto toTextBoxCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
344 SCH_TEXT_T } ) )
345 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
346
347 auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( { SCH_BUS_WIRE_ENTRY_T,
349
350 auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
351
352 //
353 // Add edit actions to the move tool menu
354 //
355 if( moveTool )
356 {
357 CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
358
359 moveMenu.AddSeparator();
360 moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
361 moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
362 moveMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition );
363 moveMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition );
365
366 moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
367
368 CONDITIONAL_MENU* editMoveItemSubMenu = new CONDITIONAL_MENU(moveTool);
369 editMoveItemSubMenu->SetTitle( _( "Edit Main Fields" ) );
370 editMoveItemSubMenu->SetIcon( BITMAPS::right );
371 moveMenu.AddMenu( editMoveItemSubMenu, E_C::SingleSymbol );
372
373 editMoveItemSubMenu->AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol );
374 editMoveItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol );
375 editMoveItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol );
376
378
379 std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
380 symUnitMenu->SetTool( this );
381 m_menu.RegisterSubMenu( symUnitMenu );
382 moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
383
384 moveMenu.AddSeparator();
388 moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
389 }
390
391 //
392 // Add editing actions to the drawing tool menu
393 //
394 CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
395
396 drawMenu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 );
397 drawMenu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 );
398
399 drawMenu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 );
400 drawMenu.AddSeparator( sheetSelection && EE_CONDITIONS::Idle, 1 );
401
402 drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
403 drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
404 drawMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
405 drawMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
406
407 drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
408
409 CONDITIONAL_MENU* editDrawItemSubMenu = new CONDITIONAL_MENU( drawingTools );
410 editDrawItemSubMenu->SetTitle( _( "Edit Main Fields" ) );
411 editDrawItemSubMenu->SetIcon( BITMAPS::right );
412 drawMenu.AddMenu( editDrawItemSubMenu, E_C::SingleSymbol, 200 );
413
414 editDrawItemSubMenu->AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol, 200 );
415 editDrawItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
416 editDrawItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 );
417
419
420 drawMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 );
421
422 std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
423 symUnitMenu2->SetTool( drawingTools );
424 drawingTools->GetToolMenu().RegisterSubMenu( symUnitMenu2 );
425 drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
426
428
429 drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
430 drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
431 drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
432 drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
433 drawMenu.AddItem( EE_ACTIONS::toTextBox, anyTextTool && E_C::Idle, 200 );
434
435 //
436 // Add editing actions to the selection tool menu
437 //
439
440 selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
441 selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
442 selToolMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
443 selToolMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
445
446 selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
447
448 CONDITIONAL_MENU* editSelItemSubMenu = new CONDITIONAL_MENU( moveTool );
449 editSelItemSubMenu->SetTitle( _( "Edit Main Fields" ) );
450 editSelItemSubMenu->SetIcon( BITMAPS::right );
451 selToolMenu.AddMenu( editSelItemSubMenu, E_C::SingleSymbol, 200 );
452
453 editSelItemSubMenu->AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol, 200 );
454 editSelItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
455 editSelItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 );
456
457 selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 );
459
460 std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
461 symUnitMenu3->SetTool( m_selectionTool );
463 selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
464
470
471 CONDITIONAL_MENU* convertToSubMenu = new CONDITIONAL_MENU( m_selectionTool );
472 convertToSubMenu->SetTitle( _( "Change To" ) );
473 convertToSubMenu->SetIcon( BITMAPS::right );
474 selToolMenu.AddMenu( convertToSubMenu, toChangeCondition, 200 );
475
476 convertToSubMenu->AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
477 convertToSubMenu->AddItem( EE_ACTIONS::toCLabel, toCLabelCondition, 200 );
478 convertToSubMenu->AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
479 convertToSubMenu->AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
480 convertToSubMenu->AddItem( EE_ACTIONS::toText, toTextCondition, 200 );
481 convertToSubMenu->AddItem( EE_ACTIONS::toTextBox, toTextBoxCondition, 200 );
482
483 selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetHasUndefinedPins, 250 );
484
485 selToolMenu.AddSeparator( 300 );
486 selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
487 selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
488 selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
489 selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
490 selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 300 );
491 selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
492
493 selToolMenu.AddSeparator( 400 );
494 selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
495
496
497 return true;
498}
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION duplicate
Definition: actions.h:72
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION selectAll
Definition: actions.h:71
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const VECTOR2I &aPosition)
static TOOL_ACTION mirrorV
Definition: ee_actions.h:125
static TOOL_ACTION properties
Definition: ee_actions.h:128
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:267
static TOOL_ACTION toGLabel
Definition: ee_actions.h:140
static TOOL_ACTION cleanupSheetPins
Definition: ee_actions.h:210
static TOOL_ACTION toText
Definition: ee_actions.h:141
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:88
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:132
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:124
static TOOL_ACTION toLabel
Definition: ee_actions.h:137
static TOOL_ACTION toTextBox
Definition: ee_actions.h:142
static TOOL_ACTION mirrorH
Definition: ee_actions.h:126
static TOOL_ACTION rotateCW
Definition: ee_actions.h:123
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:170
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:90
static TOOL_ACTION enterSheet
Definition: ee_actions.h:199
static TOOL_ACTION updateSymbols
Definition: ee_actions.h:157
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:93
static TOOL_ACTION toCLabel
Definition: ee_actions.h:138
static TOOL_ACTION placeLabel
Definition: ee_actions.h:87
static TOOL_ACTION toHLabel
Definition: ee_actions.h:139
static TOOL_ACTION swap
Definition: ee_actions.h:127
static TOOL_ACTION toggleDeMorgan
Definition: ee_actions.h:133
static TOOL_ACTION updateSymbol
Definition: ee_actions.h:159
static SELECTION_CONDITION SingleSymbol
static SELECTION_CONDITION SingleSymbolOrPower
static SELECTION_CONDITION SingleMultiUnitSymbol
static SELECTION_CONDITION SingleDeMorganSymbol
static SELECTION_CONDITION MultipleSymbolsOrPower
bool empty() const
Definition: sch_rtree.h:176
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:66
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:102
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:410
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
const SCH_CONNECTION * GetHighlightedConnection() const
virtual bool HasLineStroke() const
Check if this schematic item has line stoke properties.
Definition: sch_item.h:455
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
static SELECTION_CONDITION HasTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if among the selected items there is at least one of a given types.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool IdleSelection(const SELECTION &aSelection)
Test if all selected items are not being edited.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
bool IsCurrentTool(const TOOL_ACTION &aAction) const
TOOL_MENU & GetToolMenu()
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:50
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:382
@ SCH_SHAPE_T
Definition: typeinfo.h:147
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:145
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:144
@ SCH_BITMAP_T
Definition: typeinfo.h:148

References _, CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), CONDITIONAL_MENU::AddSeparator(), EE_ACTIONS::autoplaceFields, EE_ACTIONS::changeSymbol, EE_ACTIONS::changeSymbols, EE_ACTIONS::cleanupSheetPins, EE_ACTIONS::clearHighlight, ACTIONS::copy, SELECTION_CONDITIONS::Count(), cursor, ACTIONS::cut, ACTIONS::doDelete, ACTIONS::duplicate, EE_ACTIONS::editFootprint, EE_ACTIONS::editReference, EE_ACTIONS::editValue, EE_ACTIONS::editWithLibEdit, EE_RTREE::empty(), EE_ACTIONS::enterSheet, EE_COLLECTOR::FieldOwners, SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::SCH_VIEW::GetDrawingSheet(), SCH_EDIT_FRAME::GetHighlightedConnection(), TOOL_MENU::GetMenu(), SCH_EDIT_FRAME::GetScreen(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), TOOL_BASE::getView(), SCH_DRAW_PANEL::GetView(), TOOL_BASE::getViewControls(), SCH_ITEM::HasLineStroke(), SELECTION_CONDITIONS::HasTypes(), DS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), EE_TOOL_BASE< T >::Init(), SCH_ITEM::IsConnectable(), TOOLS_HOLDER::IsCurrentTool(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), KIGFX::VIEW::IsLayerVisible(), SCH_SCREEN::Items(), LAYER_SCHEMATIC_DRAWINGSHEET, 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::mirrorH, EE_ACTIONS::mirrorV, SELECTION_CONDITIONS::MoreThan(), EE_CONDITIONS::MultipleSymbolsOrPower, SELECTION_CONDITIONS::NotEmpty(), SELECTION_CONDITIONS::OnlyTypes(), ACTIONS::paste, ACTIONS::pasteSpecial, EE_ACTIONS::placeClassLabel, EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, EE_ACTIONS::placeLabel, EE_ACTIONS::placeSchematicText, EE_ACTIONS::properties, TOOL_MENU::RegisterSubMenu(), right, RotatableItems, EE_ACTIONS::rotateCCW, EE_ACTIONS::rotateCW, SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_DIRECTIVE_LABEL_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_SHAPE_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, SCH_TEXTBOX_T, ACTIONS::selectAll, ACTION_MENU::SetIcon(), ACTION_MENU::SetTitle(), EE_CONDITIONS::SingleDeMorganSymbol, EE_CONDITIONS::SingleMultiUnitSymbol, EE_CONDITIONS::SingleSymbol, EE_CONDITIONS::SingleSymbolOrPower, EE_ACTIONS::swap, EE_ACTIONS::toCLabel, EE_ACTIONS::toggleDeMorgan, EE_ACTIONS::toGLabel, EE_ACTIONS::toHLabel, EE_ACTIONS::toLabel, EE_ACTIONS::toText, EE_ACTIONS::toTextBox, EDA_ITEM::Type(), EE_ACTIONS::updateSymbol, and EE_ACTIONS::updateSymbols.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32{
34}
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

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

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

◆ Mirror()

int SCH_EDIT_TOOL::Mirror ( const TOOL_EVENT aEvent)

Definition at line 788 of file sch_edit_tool.cpp.

789{
791
792 if( selection.GetSize() == 0 )
793 return 0;
794
795 bool vertical = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) );
796 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
797 bool connections = false;
798 bool moving = item->IsMoving();
799
800 if( selection.GetSize() == 1 )
801 {
802 if( !moving )
804
805 switch( item->Type() )
806 {
807 case SCH_SYMBOL_T:
808 {
809 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
810
811 if( vertical )
812 symbol->SetOrientation( SYM_MIRROR_X );
813 else
814 symbol->SetOrientation( SYM_MIRROR_Y );
815
816 symbol->ClearFieldsAutoplaced();
817 break;
818 }
819
820 case SCH_TEXT_T:
821 case SCH_LABEL_T:
823 case SCH_HIER_LABEL_T:
825 {
826 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
827 textItem->MirrorSpinStyle( !vertical );
828 break;
829 }
830
831 case SCH_SHEET_PIN_T:
832 {
833 // mirror within parent sheet
834 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
835 SCH_SHEET* sheet = pin->GetParent();
836
837 if( vertical )
838 pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
839 else
840 pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
841
842 break;
843 }
844
845 case SCH_FIELD_T:
846 {
847 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
848
849 if( vertical )
850 field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
851 else
852 field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) );
853
854 // Now that we're re-justifying a field, they're no longer autoplaced.
855 static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
856
857 break;
858 }
859
860 case SCH_BITMAP_T:
861 if( vertical )
862 item->MirrorVertically( item->GetPosition().y );
863 else
864 item->MirrorHorizontally( item->GetPosition().x );
865
866 // The bitmap is cached in Opengl: clear the cache to redraw
868 break;
869
870 case SCH_SHEET_T:
871 {
872 // Mirror the sheet on itself. Sheets do not have a anchor point.
874
875 if( vertical )
876 item->MirrorVertically( mirrorPoint.y );
877 else
878 item->MirrorHorizontally( mirrorPoint.x );
879
880 break;
881 }
882
883 default:
884 if( vertical )
885 item->MirrorVertically( item->GetPosition().y );
886 else
887 item->MirrorHorizontally( item->GetPosition().x );
888
889 break;
890 }
891
892 connections = item->IsConnectable();
893 m_frame->UpdateItem( item, false, true );
894 }
895 else if( selection.GetSize() > 1 )
896 {
897 VECTOR2I mirrorPoint = m_frame->GetNearestHalfGridPosition( selection.GetCenter() );
898
899 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
900 {
901 item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
902
903 if( !moving )
904 saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
905
906 if( item->Type() == SCH_SHEET_PIN_T )
907 {
908 if( item->GetParent()->IsSelected() )
909 {
910 // parent will mirror us
911 }
912 else
913 {
914 // mirror within parent sheet
915 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
916 SCH_SHEET* sheet = pin->GetParent();
917
918 if( vertical )
919 pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
920 else
921 pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
922 }
923 }
924 else if( item->Type() == SCH_FIELD_T )
925 {
926 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
927
928 if( vertical )
929 field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
930 else
931 field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) );
932
933 // Now that we're re-justifying a field, they're no longer autoplaced.
934 static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
935 }
936 else
937 {
938 if( vertical )
939 item->MirrorVertically( mirrorPoint.y );
940 else
941 item->MirrorHorizontally( mirrorPoint.x );
942 }
943
944 connections |= item->IsConnectable();
945 m_frame->UpdateItem( item, false, true );
946 }
947 }
948
950
951 // Update R-Tree for modified items
952 for( EDA_ITEM* selected : selection )
953 updateItem( selected, true );
954
955 if( item->IsMoving() )
956 {
958 }
959 else
960 {
961 EE_SELECTION selectionCopy = selection;
962
963 if( selection.IsHover() )
965
966 if( connections )
967 {
969 lwbTool->TrimOverLappingWires( &selectionCopy );
970 lwbTool->AddJunctionsIfNeeded( &selectionCopy );
971
974 }
975
976 m_frame->OnModify();
977 }
978
979 return 0;
980}
const Vec GetCenter() const
Definition: box2.h:195
VECTOR2I GetNearestHalfGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:250
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1384
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
virtual void MirrorVertically(int aCenter)=0
Mirror item vertically about aCenter.
virtual void MirrorHorizontally(int aCenter)=0
Mirror item horizontally about aCenter.
void ClearFieldsAutoplaced()
Definition: sch_item.h:427
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
int AddJunctionsIfNeeded(EE_SELECTION *aSelection)
Handle the addition of junctions to a selection of objects.
int TrimOverLappingWires(EE_SELECTION *aSelection)
Logic to remove wires when overlapping correct items.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_sheet.cpp:683
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:179
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.cpp:93
@ SYM_MIRROR_Y
@ SYM_MIRROR_X
#define TO_VJUSTIFY(x)
#define TO_HJUSTIFY(x)

References SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), BOX2< Vec >::Centre(), CHANGED, SCH_ITEM::ClearFieldsAutoplaced(), EE_ACTIONS::clearSelection, SELECTION::Front(), EDA_ITEM::GetBoundingBox(), SCH_SHEET::GetBoundingBox(), SELECTION::GetCenter(), BOX2< Vec >::GetCenter(), EDA_TEXT::GetHorizJustify(), SELECTION::GetItem(), EDA_DRAW_FRAME::GetNearestHalfGridPosition(), EDA_ITEM::GetParent(), EDA_ITEM::GetPosition(), SELECTION::GetSize(), TOOL_MANAGER::GetTool(), EDA_TEXT::GetVertJustify(), TOOL_BASE::getView(), SCH_ITEM::IsConnectable(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_EVENT::Matches(), SCH_ITEM::MirrorHorizontally(), SCH_TEXT::MirrorSpinStyle(), EE_ACTIONS::mirrorV, SCH_ITEM::MirrorVertically(), SCH_EDIT_FRAME::OnModify(), pin, TOOL_MANAGER::PostEvent(), KIGFX::VIEW::RecacheAllItems(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), RotatableItems, TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_BITMAP_T, SCH_DIRECTIVE_LABEL_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, SCH_EDIT_FRAME::SchematicCleanUp(), EVENTS::SelectedItemsModified, EDA_TEXT::SetHorizJustify(), SCH_SYMBOL::SetOrientation(), EDA_TEXT::SetVertJustify(), SYM_MIRROR_X, SYM_MIRROR_Y, SCH_EDIT_FRAME::TestDanglingEnds(), TO_HJUSTIFY, TO_VJUSTIFY, SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires(), EDA_ITEM::Type(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem(), SCH_EDIT_FRAME::UpdateItem(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ Properties()

int SCH_EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

Definition at line 1566 of file sch_edit_tool.cpp.

1567{
1569 bool clearSelection = selection.IsHover();
1570
1571 if( selection.Empty() )
1572 {
1573 if( getView()->IsLayerVisible( LAYER_SCHEMATIC_DRAWINGSHEET ) )
1574 {
1576 VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1577
1578 if( ds && ds->HitTestDrawingSheetItems( getView(), cursorPos ) )
1580 }
1581
1582 return 0;
1583 }
1584
1585 EDA_ITEM* curr_item = selection.Front();
1586
1587 switch( curr_item->Type() )
1588 {
1589 case SCH_LINE_T:
1591 case SCH_JUNCTION_T:
1592 break;
1593
1594 default:
1595 if( selection.Size() > 1 )
1596 return 0;
1597
1598 break;
1599 }
1600
1601 switch( curr_item->Type() )
1602 {
1603 case SCH_SYMBOL_T:
1604 {
1605 int retval;
1606 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( curr_item );
1607
1608 // This needs to be scoped so the dialog destructor removes blocking status
1609 // before we launch the next dialog.
1610 {
1611 DIALOG_SYMBOL_PROPERTIES symbolPropsDialog( m_frame, symbol );
1612
1613 // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
1614 // frame. Therefore this dialog as a modal frame parent, MUST be run under
1615 // quasimodal mode for the quasimodal frame support to work. So don't use
1616 // the QUASIMODAL macros here.
1617 retval = symbolPropsDialog.ShowQuasiModal();
1618 }
1619
1620 if( retval == SYMBOL_PROPS_EDIT_OK )
1621 {
1624
1626 m_frame->OnModify();
1627 }
1628 else if( retval == SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL )
1629 {
1631 true );
1632
1633 if( wxWindow* blocking_win = editor->Kiway().GetBlockingDialog() )
1634 blocking_win->Close( true );
1635
1636 // The broken library symbol link indicator cannot be edited.
1637 if( symbol->IsMissingLibSymbol() )
1638 return 0;
1639
1640 editor->LoadSymbolFromSchematic( symbol );
1641
1642 editor->Show( true );
1643 editor->Raise();
1644 }
1645 else if( retval == SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL )
1646 {
1648 true );
1649
1650 if( wxWindow* blocking_win = editor->Kiway().GetBlockingDialog() )
1651 blocking_win->Close( true );
1652
1653 editor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbol->GetConvert() );
1654
1655 editor->Show( true );
1656 editor->Raise();
1657 }
1658 else if( retval == SYMBOL_PROPS_WANT_UPDATE_SYMBOL )
1659 {
1661 dlg.ShowQuasiModal();
1662 }
1663 else if( retval == SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL )
1664 {
1666 dlg.ShowQuasiModal();
1667 }
1668 }
1669 break;
1670
1671 case SCH_SHEET_T:
1672 {
1673 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( curr_item );
1674 bool doClearAnnotation;
1675 bool doRefresh = false;
1676
1677 // Keep track of existing sheet paths. EditSheet() can modify this list.
1678 // Note that we use the validity checking/repairing version here just to make sure
1679 // we've got a valid hierarchy to begin with.
1680 SCH_SHEET_LIST originalHierarchy( &m_frame->Schematic().Root(), true );
1681
1682 doRefresh = m_frame->EditSheetProperties( sheet, &m_frame->GetCurrentSheet(),
1683 &doClearAnnotation );
1684
1685 // If the sheet file is changed and new sheet contents are loaded then we have to
1686 // clear the annotations on the new content (as it may have been set from some other
1687 // sheet path reference)
1688 if( doClearAnnotation )
1689 {
1690 SCH_SCREENS screensList( &m_frame->Schematic().Root() );
1691
1692 // We clear annotation of new sheet paths here:
1693 screensList.ClearAnnotationOfNewSheetPaths( originalHierarchy );
1694
1695 // Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
1696 // path, but symbols managed by its sheet path must have their annotation cleared
1697 // because they are new:
1698 sheet->GetScreen()->ClearAnnotation( &m_frame->GetCurrentSheet(), false );
1699 }
1700
1701 if( doRefresh )
1702 {
1706 }
1707
1708 break;
1709 }
1710
1711 case SCH_SHEET_PIN_T:
1712 {
1713 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( curr_item );
1715
1716 // QuasiModal required for help dialog
1717 if( dlg.ShowQuasiModal() == wxID_OK )
1718 {
1720 m_frame->OnModify();
1721 }
1722 }
1723 break;
1724
1725 case SCH_TEXT_T:
1726 case SCH_TEXTBOX_T:
1727 {
1728 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_ITEM*>( curr_item ) );
1729
1730 // Must be quasi modal for syntax help
1731 if( dlg.ShowQuasiModal() == wxID_OK )
1732 {
1734 m_frame->OnModify();
1735 }
1736 }
1737 break;
1738
1739 case SCH_LABEL_T:
1740 case SCH_GLOBAL_LABEL_T:
1741 case SCH_HIER_LABEL_T:
1743 {
1744 DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast<SCH_LABEL_BASE*>( curr_item ) );
1745
1746 // Must be quasi modal for syntax help
1747 if( dlg.ShowQuasiModal() == wxID_OK )
1748 {
1750 m_frame->OnModify();
1751 }
1752 }
1753 break;
1754
1755 case SCH_FIELD_T:
1756 {
1757 SCH_FIELD* field = static_cast<SCH_FIELD*>( curr_item );
1758
1759 editFieldText( field );
1760
1761 if( !field->IsVisible() )
1762 clearSelection = true;
1763 }
1764 break;
1765
1766 case SCH_SHAPE_T:
1767 {
1768 DIALOG_SHAPE_PROPERTIES dlg( m_frame, static_cast<SCH_SHAPE*>( curr_item ) );
1769
1770 if( dlg.ShowModal() == wxID_OK )
1771 {
1773 m_frame->OnModify();
1774 }
1775 }
1776 break;
1777
1778 case SCH_BITMAP_T:
1779 {
1780 SCH_BITMAP* bitmap = static_cast<SCH_BITMAP*>( curr_item );
1781 DIALOG_IMAGE_PROPERTIES dlg( m_frame, bitmap );
1782
1783 if( dlg.ShowModal() == wxID_OK )
1784 {
1785 // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1788 m_frame->OnModify();
1789 }
1790 }
1791 break;
1792
1793 case SCH_LINE_T:
1795 case SCH_JUNCTION_T:
1796 if( std::all_of( selection.Items().begin(), selection.Items().end(),
1797 [&]( const EDA_ITEM* item )
1798 {
1799 return item->Type() == SCH_LINE_T
1800 && static_cast<const SCH_LINE*>( item )->IsGraphicLine();
1801 } ) )
1802 {
1803 std::deque<SCH_LINE*> lines;
1804
1805 for( EDA_ITEM* selItem : selection.Items() )
1806 lines.push_back( static_cast<SCH_LINE*>( selItem ) );
1807
1808 DIALOG_LINE_PROPERTIES dlg( m_frame, lines );
1809
1810 if( dlg.ShowModal() == wxID_OK )
1811 {
1813 m_frame->OnModify();
1814 }
1815 }
1816 else if( std::all_of( selection.Items().begin(), selection.Items().end(),
1817 [&]( const EDA_ITEM* item )
1818 {
1819 return item->Type() == SCH_JUNCTION_T;
1820 } ) )
1821 {
1822 std::deque<SCH_JUNCTION*> junctions;
1823
1824 for( EDA_ITEM* selItem : selection.Items() )
1825 junctions.push_back( static_cast<SCH_JUNCTION*>( selItem ) );
1826
1827 DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
1828
1829 if( dlg.ShowModal() == wxID_OK )
1830 {
1832 m_frame->OnModify();
1833 }
1834 }
1835 else if( std::all_of( selection.Items().begin(), selection.Items().end(),
1836 [&]( const EDA_ITEM* item )
1837 {
1838 const SCH_ITEM* schItem = dynamic_cast<const SCH_ITEM*>( item );
1839
1840 wxCHECK( schItem, false );
1841
1842 return ( schItem->HasLineStroke() && schItem->IsConnectable() )
1843 || item->Type() == SCH_JUNCTION_T;
1844 } ) )
1845 {
1846 std::deque<SCH_ITEM*> items;
1847
1848 for( EDA_ITEM* selItem : selection.Items() )
1849 items.push_back( static_cast<SCH_ITEM*>( selItem ) );
1850
1851 DIALOG_WIRE_BUS_PROPERTIES dlg( m_frame, items );
1852
1853 if( dlg.ShowModal() == wxID_OK )
1854 {
1856 m_frame->OnModify();
1857 }
1858 }
1859 else
1860 {
1861 return 0;
1862 }
1863
1864 break;
1865
1866 case SCH_MARKER_T: // These items have no properties to edit
1867 case SCH_NO_CONNECT_T:
1868 break;
1869
1870 default: // Unexpected item
1871 wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + curr_item->GetClass() );
1872 }
1873
1874 updateItem( curr_item, true );
1875
1876 if( clearSelection )
1878
1879 return 0;
1880}
static TOOL_ACTION pageSettings
Definition: actions.h:56
Dialog used to edit SCH_SYMBOL objects in a schematic.
virtual wxString GetClass() const =0
Return the class name.
static const std::vector< KICAD_T > EditableItems
Definition: ee_collectors.h:42
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
SCH_SHEET & Root() const
Definition: schematic.h:91
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
SCHEMATIC & Schematic() const
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:528
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:436
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:662
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear the annotation for the symbols in aSheetPath on the screen.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:106
int GetUnit() const
Definition: sch_symbol.h:228
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:239
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:213
The symbol library editor main window.
@ SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL
@ SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL
@ SYMBOL_PROPS_WANT_UPDATE_SYMBOL
@ SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL
@ SYMBOL_PROPS_EDIT_OK
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:143
@ SCH_MARKER_T
Definition: typeinfo.h:141

References SCH_ITEM::AutoAutoplaceFields(), DIALOG_CHANGE_SYMBOLS::CHANGE, SCH_SCREEN::ClearAnnotation(), SCH_SCREENS::ClearAnnotationOfNewSheetPaths(), EE_ACTIONS::clearSelection, EE_COLLECTOR::EditableItems, editFieldText(), editor, SCH_EDIT_FRAME::EditSheetProperties(), SCH_BASE_FRAME::eeconfig(), SELECTION::Empty(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, FRAME_SCH_SYMBOL_EDITOR, SELECTION::Front(), SCH_BASE_FRAME::GetCanvas(), EDA_ITEM::GetClass(), SCH_SYMBOL::GetConvert(), SCH_EDIT_FRAME::GetCurrentSheet(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::SCH_VIEW::GetDrawingSheet(), SCH_SYMBOL::GetLibId(), SCH_SHEET::GetScreen(), SCH_EDIT_FRAME::GetScreen(), SCH_SYMBOL::GetUnit(), TOOL_BASE::getView(), SCH_DRAW_PANEL::GetView(), TOOL_BASE::getViewControls(), DS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems(), SELECTION::IsHover(), SCH_SYMBOL::IsMissingLibSymbol(), EDA_TEXT::IsVisible(), SELECTION::Items(), KIWAY_HOLDER::Kiway(), LAYER_SCHEMATIC_DRAWINGSHEET, 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, pin, KIWAY::Player(), TOOL_MANAGER::PostEvent(), KIGFX::VIEW::RecacheAllItems(), EDA_DRAW_PANEL_GAL::Refresh(), EE_SELECTION_TOOL::RequestSelection(), SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), SCH_BITMAP_T, SCH_BUS_WIRE_ENTRY_T, SCH_DIRECTIVE_LABEL_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_SHAPE_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, SCH_TEXTBOX_T, SCH_EDIT_FRAME::Schematic(), EVENTS::SelectedItemsModified, DIALOG_SHIM::ShowQuasiModal(), SELECTION::Size(), SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL, SYMBOL_PROPS_EDIT_OK, SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL, SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL, SYMBOL_PROPS_WANT_UPDATE_SYMBOL, EDA_ITEM::Type(), DIALOG_CHANGE_SYMBOLS::UPDATE, SCH_EDIT_FRAME::UpdateHierarchyNavigator(), and EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem().

Referenced by setTransitions().

◆ RepeatDrawItem()

int SCH_EDIT_TOOL::RepeatDrawItem ( const TOOL_EVENT aEvent)

Definition at line 1085 of file sch_edit_tool.cpp.

1086{
1087 const std::vector<std::unique_ptr<SCH_ITEM>>& sourceItems = m_frame->GetRepeatItems();
1088
1089 if( sourceItems.empty() )
1090 return 0;
1091
1093
1094 bool appendUndo = false;
1095 EE_SELECTION newItems;
1096
1097 for( const std::unique_ptr<SCH_ITEM>& item : sourceItems )
1098 {
1099 SCH_ITEM* newItem = item->Duplicate();
1100 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1101
1102 if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( newItem ) )
1103 {
1104 // If incrementing tries to go below zero, tell user why the value is repeated
1105
1106 if( !label->IncrementLabel( cfg->m_Drawing.repeat_label_increment ) )
1107 m_frame->ShowInfoBarWarning( _( "Label value cannot go below zero" ), true );
1108 }
1109
1110 // If cloning a symbol then put into 'move' mode.
1111 if( newItem->Type() == SCH_SYMBOL_T )
1112 {
1113 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( true );
1114 newItem->Move( cursorPos - newItem->GetPosition() );
1115 }
1116 else
1117 {
1120 }
1121
1122 m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newItem );
1123 newItem->SetFlags( IS_NEW );
1124 m_frame->AddToScreen( newItem, m_frame->GetScreen() );
1125 m_frame->SaveCopyInUndoList( m_frame->GetScreen(), newItem, UNDO_REDO::NEWITEM, appendUndo );
1126 appendUndo = true;
1127
1128 if( newItem->Type() == SCH_SYMBOL_T )
1129 {
1131 SCHEMATIC_SETTINGS& projSettings = m_frame->Schematic().Settings();
1132 int annotateStartNum = projSettings.m_AnnotateStartNum;
1133
1134 if( annotate.automatic )
1135 {
1136 static_cast<SCH_SYMBOL*>( newItem )->ClearAnnotation( nullptr, false );
1137 NULL_REPORTER reporter;
1139 (ANNOTATE_ORDER_T) annotate.sort_order,
1140 (ANNOTATE_ALGO_T) annotate.method, true /* recursive */,
1141 annotateStartNum, false, false, reporter, appendUndo );
1142 }
1143
1145 }
1146
1147 newItems.Add( newItem );
1148
1149 newItem->ClearFlags();
1150 }
1151
1152 if( !newItems.Empty() )
1153 {
1155 lwbTool->TrimOverLappingWires( &newItems );
1156 lwbTool->AddJunctionsIfNeeded( &newItems );
1157
1160 }
1161
1163 m_frame->OnModify();
1164
1165 if( !newItems.Empty() )
1166 m_frame->SaveCopyForRepeatItem( static_cast<SCH_ITEM*>( newItems[0] ) );
1167
1168 for( size_t ii = 1; ii < newItems.GetSize(); ++ii )
1169 m_frame->AddCopyForRepeatItem( static_cast<SCH_ITEM*>( newItems[ii] ) );
1170
1171 return 0;
1172}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
void ShowInfoBarWarning(const wxString &aWarningMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left ...
PANEL_ANNOTATE m_AnnotatePanel
static TOOL_ACTION move
Definition: ee_actions.h:120
A singleton reporter that reports to nowhere.
Definition: reporter.h:223
These settings were stored in SCH_BASE_FRAME previously.
const std::vector< std::unique_ptr< SCH_ITEM > > & GetRepeatItems() const
Return the items which are to be repeated with the insert key.
void AddCopyForRepeatItem(const SCH_ITEM *aItem)
void AnnotateSymbols(ANNOTATE_SCOPE_T aAnnotateScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, REPORTER &aReporter, bool appendUndo=false)
Annotate the symbols in the schematic that are not currently annotated.
Definition: annotate.cpp:194
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
virtual void Move(const VECTOR2I &aMoveVector)=0
Move the item by aMoveVector to a new position.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:93
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:42
#define IS_NEW
New item, just created.
ANNOTATE_ORDER_T
Schematic annotation order options.
@ ANNOTATE_SELECTION
Annotate the selection.
ANNOTATE_ALGO_T
Schematic annotation type options.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94

References _, SELECTION::Add(), SCH_EDIT_FRAME::AddCopyForRepeatItem(), EE_ACTIONS::addItemToSel, SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), SCH_BASE_FRAME::AddToScreen(), annotate, ANNOTATE_SELECTION, SCH_EDIT_FRAME::AnnotateSymbols(), EDA_ITEM::ClearFlags(), EE_ACTIONS::clearSelection, EESCHEMA_SETTINGS::DRAWING::default_repeat_offset_x, EESCHEMA_SETTINGS::DRAWING::default_repeat_offset_y, SCH_ITEM::Duplicate(), SCH_BASE_FRAME::eeconfig(), SELECTION::Empty(), SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EDA_ITEM::GetPosition(), SCH_EDIT_FRAME::GetRepeatItems(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), TOOL_MANAGER::GetTool(), TOOL_BASE::getViewControls(), IS_NEW, EESCHEMA_SETTINGS::m_AnnotatePanel, SCHEMATIC_SETTINGS::m_AnnotateStartNum, EESCHEMA_SETTINGS::m_Drawing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, EDA_IU_SCALE::MilsToIU(), SCH_ITEM::Move(), EE_ACTIONS::move, NEWITEM, SCH_EDIT_FRAME::OnModify(), Pgm(), EDA_DRAW_PANEL_GAL::Refresh(), EESCHEMA_SETTINGS::DRAWING::repeat_label_increment, TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), SCH_EDIT_FRAME::SchematicCleanUp(), schIUScale, EDA_ITEM::SetFlags(), SCHEMATIC::Settings(), EDA_BASE_FRAME::ShowInfoBarWarning(), SCH_EDIT_FRAME::TestDanglingEnds(), SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ Reset()

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

Bring the tool to a known, initial state.

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

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 86 of file ee_tool_base.h.

87 {
88 if( aReason == MODEL_RELOAD )
89 {
90 // Init variables used by every drawing tool
91 m_frame = getEditFrame<T>();
92 m_isSymbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) != nullptr;
93 }
94
95 m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
96 }

◆ resetTransitions()

void TOOL_INTERACTIVE::resetTransitions ( )
privateinherited

Clear the current transition map and restores the default one created by setTransitions().

Definition at line 63 of file tool_interactive.cpp.

64{
67}
virtual void setTransitions()=0
This method is meant to be overridden in order to specify handlers for events.
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.

References TOOL_MANAGER::ClearTransitions(), TOOL_BASE::m_toolMgr, and TOOL_INTERACTIVE::setTransitions().

◆ Rotate()

int SCH_EDIT_TOOL::Rotate ( const TOOL_EVENT aEvent)

Definition at line 522 of file sch_edit_tool.cpp.

523{
524 bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
526
527 if( selection.GetSize() == 0 )
528 return 0;
529
530 SCH_ITEM* head = nullptr;
531 int principalItemCount = 0; // User-selected items (as opposed to connected wires)
532 VECTOR2I rotPoint;
533 bool moving = false;
534
535 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
536 {
537 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
538
539 if( item->HasFlag( SELECTED_BY_DRAG ) )
540 continue;
541
542 principalItemCount++;
543
544 if( !head )
545 head = item;
546 }
547
548 if( head && head->IsMoving() )
549 moving = true;
550
551 if( principalItemCount == 1 )
552 {
553 if( moving && selection.HasReferencePoint() )
554 rotPoint = selection.GetReferencePoint();
555 else if( head->IsConnectable() )
556 rotPoint = head->GetPosition();
557 else
559
560 if( !moving )
562
563 switch( head->Type() )
564 {
565 case SCH_SYMBOL_T:
566 {
567 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( head );
568
569 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
570 symbol->Rotate( rotPoint );
571
574
575 break;
576 }
577
578 case SCH_TEXT_T:
579 case SCH_LABEL_T:
581 case SCH_HIER_LABEL_T:
583 {
584 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( head );
585 textItem->Rotate90( clockwise );
586 break;
587 }
588
589 case SCH_SHEET_PIN_T:
590 {
591 // Rotate pin within parent sheet
592 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( head );
593 SCH_SHEET* sheet = pin->GetParent();
594
595 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
596 pin->Rotate( sheet->GetBodyBoundingBox().GetCenter() );
597
598 break;
599 }
600
601 case SCH_LINE_T:
602 {
603 SCH_LINE* line = static_cast<SCH_LINE*>( head );
604
605 // Equal checks for both and neither. We need this because on undo
606 // the item will have both flags cleared, but will be selected, so it is possible
607 // for the user to get a selected line with neither endpoint selected. We
608 // set flags to make sure Rotate() works when we call it.
609 if( line->HasFlag( STARTPOINT ) == line->HasFlag( ENDPOINT ) )
610 {
611 line->SetFlags( STARTPOINT | ENDPOINT );
612
613 // When we allow off grid items, the rotPoint should be set to the midpoint
614 // of the line to allow rotation around the center, and the next if
615 // should become an else-if
616 }
617
618 if( line->HasFlag( STARTPOINT ) )
619 rotPoint = line->GetEndPoint();
620 else if( line->HasFlag( ENDPOINT ) )
621 rotPoint = line->GetStartPoint();
622 }
623
625 case SCH_JUNCTION_T:
628 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
629 head->Rotate( rotPoint );
630
631 break;
632
633 case SCH_FIELD_T:
634 {
635 SCH_FIELD* field = static_cast<SCH_FIELD*>( head );
636
637 if( field->GetTextAngle().IsHorizontal() )
639 else
641
642 // Now that we're moving a field, they're no longer autoplaced.
643 static_cast<SCH_ITEM*>( head->GetParent() )->ClearFieldsAutoplaced();
644
645 break;
646 }
647
648 case SCH_SHAPE_T:
649 case SCH_TEXTBOX_T:
650 for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
651 head->Rotate( rotPoint );
652
653 break;
654
655 case SCH_BITMAP_T:
656 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
657 head->Rotate( rotPoint );
658
659 // The bitmap is cached in Opengl: clear the cache to redraw
661 break;
662
663 case SCH_SHEET_T:
664 {
665 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( head );
667
668 // Rotate the sheet on itself. Sheets do not have an anchor point.
669 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
670 sheet->Rotate( rotPoint );
671
672 break;
673 }
674
675 default:
676 UNIMPLEMENTED_FOR( head->GetClass() );
677 }
678
679 m_frame->UpdateItem( head, false, true );
680 }
681 else
682 {
683 if( moving && selection.HasReferencePoint() )
684 rotPoint = selection.GetReferencePoint();
685 else
686 rotPoint = m_frame->GetNearestHalfGridPosition( selection.GetCenter() );
687 }
688
689 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
690 {
691 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
692
693 // We've already rotated the user selected item if there was only one. We're just
694 // here to rotate the ends of wires that were attached to it.
695 if( principalItemCount == 1 && !item->HasFlag( SELECTED_BY_DRAG ) )
696 continue;
697
698 if( !moving )
699 saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
700
701 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
702 {
703 if( item->Type() == SCH_LINE_T )
704 {
705 SCH_LINE* line = (SCH_LINE*) item;
706
707 // If we are rotating more than one item, we do not have start/end
708 // points separately selected
709 if( item->HasFlag( STARTPOINT ) )
710 line->RotateStart( rotPoint );
711
712 if( item->HasFlag( ENDPOINT ) )
713 line->RotateEnd( rotPoint );
714 }
715 else if( item->Type() == SCH_SHEET_PIN_T )
716 {
717 if( item->GetParent()->IsSelected() )
718 {
719 // parent will rotate us
720 }
721 else
722 {
723 // rotate within parent
724 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
725 SCH_SHEET* sheet = pin->GetParent();
726
727 pin->Rotate( sheet->GetBodyBoundingBox().GetCenter() );
728 }
729 }
730 else if( item->Type() == SCH_FIELD_T )
731 {
732 if( item->GetParent()->IsSelected() )
733 {
734 // parent will rotate us
735 }
736 else
737 {
738 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
739
740 field->Rotate( rotPoint );
741
742 if( field->GetTextAngle().IsHorizontal() )
744 else
746
747 // Now that we're moving a field, they're no longer autoplaced.
748 static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
749 }
750 }
751 else
752 {
753 item->Rotate( rotPoint );
754 }
755 }
756
757 m_frame->UpdateItem( item, false, true );
758 updateItem( item, true );
759 }
760
762
763 if( moving )
764 {
766 }
767 else
768 {
769 EE_SELECTION selectionCopy = selection;
770
771 if( selection.IsHover() )
773
775 lwbTool->TrimOverLappingWires( &selectionCopy );
776 lwbTool->AddJunctionsIfNeeded( &selectionCopy );
777
780
781 m_frame->OnModify();
782 }
783
784 return 0;
785}
bool IsHorizontal() const
Definition: eda_angle.h:174
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_field.cpp:714
virtual void Rotate(const VECTOR2I &aCenter)=0
Rotate the item around aCenter 90 degrees in the clockwise direction.
void RotateEnd(const VECTOR2I &aCenter)
Definition: sch_line.cpp:426
void RotateStart(const VECTOR2I &aCenter)
Definition: sch_line.cpp:420
VECTOR2I GetEndPoint() const
Definition: sch_line.h:143
VECTOR2I GetStartPoint() const
Definition: sch_line.h:138
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:825
VECTOR2I GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
Definition: sch_sheet.cpp:694
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
Definition: sch_sheet.cpp:662
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:170
VECTOR2I GetReferencePoint() const
Definition: selection.h:252
bool HasReferencePoint() const
Definition: selection.h:247
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83

References SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), ANGLE_HORIZONTAL, ANGLE_VERTICAL, SCH_ITEM::AutoAutoplaceFields(), CHANGED, EE_ACTIONS::clearSelection, SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, ENDPOINT, SCH_SHEET::GetBodyBoundingBox(), EDA_ITEM::GetBoundingBox(), SELECTION::GetCenter(), BOX2< Vec >::GetCenter(), SCH_ITEM::GetClass(), SCH_LINE::GetEndPoint(), SELECTION::GetItem(), EDA_DRAW_FRAME::GetNearestHalfGridPosition(), EDA_ITEM::GetParent(), EDA_ITEM::GetPosition(), SELECTION::GetReferencePoint(), SCH_SHEET::GetRotationCenter(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), SCH_LINE::GetStartPoint(), EDA_TEXT::GetTextAngle(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), EDA_ITEM::HasFlag(), SELECTION::HasReferencePoint(), SCH_ITEM::IsConnectable(), EDA_ANGLE::IsHorizontal(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), KI_FALLTHROUGH, 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(), pin, TOOL_MANAGER::PostEvent(), KIGFX::VIEW::RecacheAllItems(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), RotatableItems, SCH_FIELD::Rotate(), SCH_SHEET::Rotate(), SCH_SYMBOL::Rotate(), SCH_ITEM::Rotate(), SCH_TEXT::Rotate90(), 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_DIRECTIVE_LABEL_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_SHAPE_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, SCH_TEXTBOX_T, SCH_EDIT_FRAME::SchematicCleanUp(), SELECTED_BY_DRAG, EVENTS::SelectedItemsModified, EDA_ITEM::SetFlags(), EDA_TEXT::SetTextAngle(), STARTPOINT, SCH_EDIT_FRAME::TestDanglingEnds(), SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires(), EDA_ITEM::Type(), UNIMPLEMENTED_FOR, EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem(), and SCH_EDIT_FRAME::UpdateItem().

Referenced by setTransitions().

◆ RunMainStack()

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

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ saveCopyInUndoList()

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

Definition at line 134 of file ee_tool_base.h.

136 {
137 wxASSERT( aItem );
138
139 KICAD_T itemType = aItem->Type();
140 bool selected = aItem->IsSelected();
141
142 // IS_SELECTED flag should not be set on undo items which were added for
143 // a drag operation.
144 if( selected && aItem->HasFlag( SELECTED_BY_DRAG ) )
145 aItem->ClearSelected();
146
147 if( m_isSymbolEditor )
148 {
149 SYMBOL_EDIT_FRAME* editFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
150 wxCHECK_RET( editFrame, wxT( "editFrame is null" ) );
151
152 editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
153 }
154 else
155 {
156 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
157 wxASSERT( editFrame );
158
159 if( editFrame )
160 {
161 if( itemType == SCH_FIELD_T )
162 {
163 editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
164 static_cast<SCH_ITEM*>( aItem->GetParent() ),
165 UNDO_REDO::CHANGED, aAppend,
166 false );
167 }
168 else if( itemType == SCH_PIN_T || itemType == SCH_SHEET_PIN_T )
169 {
170 editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
171 static_cast<SCH_ITEM*>( aItem->GetParent() ),
172 UNDO_REDO::CHANGED, aAppend,
173 aDirtyConnectivity );
174 }
175 else
176 {
177 editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
178 static_cast<SCH_ITEM*>( aItem ), aType,
179 aAppend, aDirtyConnectivity );
180 }
181 }
182 }
183
184 if( selected && aItem->HasFlag( SELECTED_BY_DRAG ) )
185 aItem->SetSelected();
186 }
void ClearSelected()
Definition: eda_item.h:118
void SetSelected()
Definition: eda_item.h:115
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
@ SCH_PIN_T
Definition: typeinfo.h:159

◆ SetContextMenu()

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

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

Referenced by SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void SCH_EDIT_TOOL::setTransitions ( )
overrideprivatevirtual

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

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 2373 of file sch_edit_tool.cpp.

2374{
2380 Go( &SCH_EDIT_TOOL::Swap, EE_ACTIONS::swap.MakeEvent() );
2383
2402
2405
2409
2411}
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION breakWire
Definition: ee_actions.h:143
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:272
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:163
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:122
static TOOL_ACTION editTextAndGraphics
Definition: ee_actions.h:211
int DeleteItemCursor(const TOOL_EVENT &aEvent)
int EditField(const TOOL_EVENT &aEvent)
int EditPageNumber(const TOOL_EVENT &aEvent)
int DoDelete(const TOOL_EVENT &aEvent)
Run the deletion tool.
int CleanupSheetPins(const TOOL_EVENT &aEvent)
int Mirror(const TOOL_EVENT &aEvent)
int GlobalEdit(const TOOL_EVENT &aEvent)
Delete the selected items, or the item under the cursor.
int Properties(const TOOL_EVENT &aEvent)
int Rotate(const TOOL_EVENT &aEvent)
int BreakWire(const TOOL_EVENT &aEvent)
int DdAppendFile(const TOOL_EVENT &aEvent)
Drag and drop.
int ConvertDeMorgan(const TOOL_EVENT &aEvent)
int AutoplaceFields(const TOOL_EVENT &aEvent)
int Swap(const TOOL_EVENT &aEvent)
int ChangeSymbols(const TOOL_EVENT &aEvent)
int ChangeTextType(const TOOL_EVENT &aEvent)
Change a text type to another one.
int RepeatDrawItem(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).

References EE_ACTIONS::autoplaceFields, AutoplaceFields(), EE_ACTIONS::breakWire, BreakWire(), EE_ACTIONS::changeSymbol, EE_ACTIONS::changeSymbols, ChangeSymbols(), ChangeTextType(), EE_ACTIONS::cleanupSheetPins, CleanupSheetPins(), ConvertDeMorgan(), EE_ACTIONS::ddAppendFile, DdAppendFile(), DeleteItemCursor(), ACTIONS::deleteTool, DoDelete(), ACTIONS::doDelete, EditField(), EE_ACTIONS::editFootprint, EE_ACTIONS::editPageNumber, EditPageNumber(), EE_ACTIONS::editReference, EE_ACTIONS::editTextAndGraphics, EE_ACTIONS::editValue, GlobalEdit(), TOOL_INTERACTIVE::Go(), Mirror(), EE_ACTIONS::mirrorH, EE_ACTIONS::mirrorV, EE_ACTIONS::properties, Properties(), EE_ACTIONS::repeatDrawItem, RepeatDrawItem(), Rotate(), EE_ACTIONS::rotateCCW, EE_ACTIONS::rotateCW, EE_ACTIONS::showDeMorganAlternate, EE_ACTIONS::showDeMorganStandard, EE_ACTIONS::slice, EE_ACTIONS::swap, Swap(), EE_ACTIONS::toCLabel, EE_ACTIONS::toggleDeMorgan, EE_ACTIONS::toGLabel, EE_ACTIONS::toHLabel, EE_ACTIONS::toLabel, EE_ACTIONS::toText, EE_ACTIONS::toTextBox, EE_ACTIONS::updateSymbol, and EE_ACTIONS::updateSymbols.

◆ Swap()

int SCH_EDIT_TOOL::Swap ( const TOOL_EVENT aEvent)

Definition at line 1000 of file sch_edit_tool.cpp.

1001{
1003 std::vector<EDA_ITEM*> sorted = selection.GetItemsSortedBySelectionOrder();
1004
1005 if( selection.Size() < 2 )
1006 return 0;
1007
1008 bool isMoving = selection.Front()->IsMoving();
1009 bool appendUndo = isMoving;
1010 bool connections = false;
1011
1012 SCH_SCREEN* screen = this->m_frame->GetScreen();
1013
1014 for( size_t i = 0; i < sorted.size() - 1; i++ )
1015 {
1016 SCH_ITEM* a = static_cast<SCH_ITEM*>( sorted[i] );
1017 SCH_ITEM* b = static_cast<SCH_ITEM*>( sorted[( i + 1 ) % sorted.size()] );
1018
1019 VECTOR2I aPos = a->GetPosition(), bPos = b->GetPosition();
1020 std::swap( aPos, bPos );
1021
1022 saveCopyInUndoList( a, UNDO_REDO::CHANGED, appendUndo );
1023 appendUndo = true;
1024 saveCopyInUndoList( b, UNDO_REDO::CHANGED, appendUndo );
1025
1026 a->SetPosition( aPos );
1027 b->SetPosition( bPos );
1028
1029 if( a->Type() == b->Type() )
1030 {
1031 switch( a->Type() )
1032 {
1033 case SCH_LABEL_T:
1034 case SCH_GLOBAL_LABEL_T:
1035 case SCH_HIER_LABEL_T:
1037 m_frame->AutoRotateItem( screen, a );
1038 m_frame->AutoRotateItem( screen, b );
1039 break;
1040 case SCH_SYMBOL_T:
1041 {
1042 SCH_SYMBOL* aSymbol = static_cast<SCH_SYMBOL*>( a );
1043 SCH_SYMBOL* bSymbol = static_cast<SCH_SYMBOL*>( b );
1044 int aOrient = aSymbol->GetOrientation(), bOrient = bSymbol->GetOrientation();
1045 std::swap( aOrient, bOrient );
1046 aSymbol->SetOrientation( aOrient );
1047 bSymbol->SetOrientation( bOrient );
1048 break;
1049 }
1050 default: break;
1051 }
1052 }
1053
1054 connections |= a->IsConnectable();
1055 connections |= b->IsConnectable();
1056 m_frame->UpdateItem( a, false, true );
1057 m_frame->UpdateItem( b, false, true );
1058 }
1059
1061
1062 // Update R-Tree for modified items
1063 for( EDA_ITEM* selected : selection )
1064 updateItem( selected, true );
1065
1066 if( isMoving )
1067 {
1069 }
1070 else
1071 {
1072 if( selection.IsHover() )
1074
1075 if( connections )
1077
1078 m_frame->OnModify();
1079 }
1080
1081 return 0;
1082}
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:250
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it)
int GetOrientation() const
Get the display symbol orientation.
const std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
Definition: selection.cpp:201
const std::vector< KICAD_T > swappableItems

References SCH_EDIT_FRAME::AutoRotateItem(), CHANGED, EE_ACTIONS::clearSelection, SELECTION::Front(), SELECTION::GetItemsSortedBySelectionOrder(), SCH_SYMBOL::GetOrientation(), EDA_ITEM::GetPosition(), SCH_EDIT_FRAME::GetScreen(), SCH_ITEM::IsConnectable(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), 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_MANAGER::PostEvent(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SYMBOL_T, EVENTS::SelectedItemsModified, SCH_SYMBOL::SetOrientation(), EDA_ITEM::SetPosition(), SELECTION::Size(), swappableItems, SCH_EDIT_FRAME::TestDanglingEnds(), EDA_ITEM::Type(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem(), and SCH_EDIT_FRAME::UpdateItem().

Referenced by setTransitions().

◆ updateItem()

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

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

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

Definition at line 103 of file ee_tool_base.h.

◆ Wait()

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

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

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_CONTROL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_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 189 of file ee_tool_base.h.

◆ m_isSymbolEditor

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isSymbolEditor
protectedinherited

Definition at line 192 of file ee_tool_base.h.

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

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

Definition at line 125 of file tool_interactive.h.

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

◆ m_pickerItem

EDA_ITEM* SCH_EDIT_TOOL::m_pickerItem
private

Definition at line 93 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 191 of file ee_tool_base.h.

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

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

Definition at line 210 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 215 of file tool_base.h.

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

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

◆ m_view

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

Definition at line 190 of file ee_tool_base.h.

◆ RotatableItems


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