KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_edit_tool.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019 CERN
5 * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <kiway.h>
26#include <tool/picker_tool.h>
27#include <tools/sch_edit_tool.h>
30#include <tools/sch_move_tool.h>
32#include <ee_actions.h>
33#include <bitmaps.h>
34#include <confirm.h>
35#include <eda_item.h>
36#include <string_utils.h>
37#include <sch_item.h>
38#include <sch_symbol.h>
39#include <sch_shape.h>
40#include <sch_sheet.h>
41#include <sch_sheet_pin.h>
42#include <sch_text.h>
43#include <sch_textbox.h>
44#include <sch_bitmap.h>
45#include <sch_view.h>
46#include <sch_line.h>
47#include <sch_bus_entry.h>
48#include <sch_junction.h>
49#include <sch_edit_frame.h>
50#include <schematic.h>
51#include <schematic_commit.h>
53#include <eeschema_id.h>
55#include <dialogs/dialog_image_properties.h>
64#include <dialogs/dialog_text_properties.h>
65#include <pgm_base.h>
68#include <core/kicad_algo.h>
69#include <wx/textdlg.h>
71
73{
74public:
76 ACTION_MENU( true )
77 {
78 SetIcon( BITMAPS::component_select_unit );
79 SetTitle( _( "Symbol Unit" ) );
80 }
81
82protected:
83 ACTION_MENU* create() const override
84 {
85 return new SYMBOL_UNIT_MENU();
86 }
87
88private:
89 void update() override
90 {
92 EE_SELECTION& selection = selTool->GetSelection();
93 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
94
95 Clear();
96
97 if( !symbol )
98 {
99 Append( ID_POPUP_SCH_SELECT_UNIT_CMP, _( "no symbol selected" ), wxEmptyString );
100 Enable( ID_POPUP_SCH_SELECT_UNIT_CMP, false );
101 return;
102 }
103
104 int unit = symbol->GetUnit();
105
106 if( !symbol->GetLibSymbolRef() || symbol->GetLibSymbolRef()->GetUnitCount() < 2 )
107 {
108 Append( ID_POPUP_SCH_SELECT_UNIT_CMP, _( "symbol is not multi-unit" ), wxEmptyString );
109 Enable( ID_POPUP_SCH_SELECT_UNIT_CMP, false );
110 return;
111 }
112
113 for( int ii = 0; ii < symbol->GetLibSymbolRef()->GetUnitCount(); ii++ )
114 {
115 wxString num_unit;
116 num_unit.Printf( _( "Unit %s" ), LIB_SYMBOL::SubReference( ii + 1, false ) );
117
118 wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
119 wxITEM_CHECK );
120 if( unit == ii + 1 )
121 item->Check(true);
122
123 // The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_SYM_MAX
124 // See eeschema_id to modify this value.
126 break; // We have used all IDs for these submenus
127 }
128 }
129};
130
131
133 EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
134{
135 m_pickerItem = nullptr;
136}
137
138
140
142{
144
147
148 wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
149
150 auto hasElements =
151 [this]( const SELECTION& aSel )
152 {
153 return !m_frame->GetScreen()->Items().empty();
154 };
155
156 auto sheetHasUndefinedPins =
157 []( const SELECTION& aSel )
158 {
159 if( aSel.Size() == 1 && aSel.Front()->Type() == SCH_SHEET_T )
160 return static_cast<SCH_SHEET*>( aSel.Front() )->HasUndefinedPins();
161
162 return false;
163 };
164
165 auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
166
167 auto haveHighlight =
168 [&]( const SELECTION& sel )
169 {
170 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
171
172 return editFrame && !editFrame->GetHighlightedConnection().IsEmpty();
173 };
174
175 auto anyTextTool =
176 [this]( const SELECTION& aSel )
177 {
183 };
184
185 auto duplicateCondition =
186 []( const SELECTION& aSel )
187 {
189 return false;
190
191 return true;
192 };
193
194 auto orientCondition =
195 []( const SELECTION& aSel )
196 {
198 return false;
199
201 };
202
203 auto propertiesCondition =
204 [&]( const SELECTION& aSel )
205 {
206 if( aSel.GetSize() == 0 )
207 {
209 {
212
213 if( ds && ds->HitTestDrawingSheetItems( getView(), cursor ) )
214 return true;
215 }
216
217 return false;
218 }
219
220 SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
221 const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
222
223 if( !firstItem || !eeSelection )
224 return false;
225
226 switch( firstItem->Type() )
227 {
228 case SCH_SYMBOL_T:
229 case SCH_SHEET_T:
230 case SCH_SHEET_PIN_T:
231 case SCH_TEXT_T:
232 case SCH_TEXTBOX_T:
233 case SCH_LABEL_T:
235 case SCH_HIER_LABEL_T:
237 case SCH_FIELD_T:
238 case SCH_SHAPE_T:
239 case SCH_BITMAP_T:
240 return aSel.GetSize() == 1;
241
242 case SCH_LINE_T:
244 case SCH_JUNCTION_T:
245 if( std::all_of( aSel.Items().begin(), aSel.Items().end(),
246 [&]( const EDA_ITEM* item )
247 {
248 return item->Type() == SCH_LINE_T
249 && static_cast<const SCH_LINE*>( item )->IsGraphicLine();
250 } ) )
251 {
252 return true;
253 }
254 else if( std::all_of( aSel.Items().begin(), aSel.Items().end(),
255 [&]( const EDA_ITEM* item )
256 {
257 return item->Type() == SCH_JUNCTION_T;
258 } ) )
259 {
260 return true;
261 }
262 else if( std::all_of( aSel.Items().begin(), aSel.Items().end(),
263 [&]( const EDA_ITEM* item )
264 {
265 const SCH_ITEM* schItem = dynamic_cast<const SCH_ITEM*>( item );
266
267 wxCHECK( schItem, false );
268
269 return ( schItem->HasLineStroke() && schItem->IsConnectable() )
270 || item->Type() == SCH_JUNCTION_T;
271 } ) )
272 {
273 return true;
274 }
275
276 return false;
277
278 default:
279 return false;
280 }
281 };
282
283 auto autoplaceCondition =
284 []( const SELECTION& aSel )
285 {
286 for( const EDA_ITEM* item : aSel )
287 {
288 if( item->IsType( EE_COLLECTOR::FieldOwners ) )
289 return true;
290 }
291
292 return false;
293 };
294
295 // allTextTypes does not include SCH_SHEET_PIN_T because one cannot convert other
296 // types to/from this type, living only in a SHEET
297 static std::vector<KICAD_T> allTextTypes = { SCH_LABEL_T,
303
304 auto toChangeCondition = ( E_C::OnlyTypes( allTextTypes ) );
305
306 auto toLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_DIRECTIVE_LABEL_T,
310 SCH_TEXTBOX_T } ) )
311 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
312
313 auto toCLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
317 SCH_TEXTBOX_T } ) )
318 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
319
320 auto toHLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
324 SCH_TEXTBOX_T } ) )
325 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
326
327 auto toGLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
331 SCH_TEXTBOX_T } ) )
332 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
333
334 auto toTextCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
338 SCH_TEXTBOX_T } ) )
339 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
340
341 auto toTextBoxCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_LABEL_T,
345 SCH_TEXT_T } ) )
346 || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allTextTypes ) );
347
348 auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( { SCH_BUS_WIRE_ENTRY_T,
350
351 auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
352
353 //
354 // Add edit actions to the move tool menu
355 //
356 if( moveTool )
357 {
358 CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
359
360 moveMenu.AddSeparator();
361
362 CONDITIONAL_MENU* transformMoveSubMenu = new CONDITIONAL_MENU( moveTool );
363 transformMoveSubMenu->SetTitle( _( "Transform Selection" ) );
364 moveMenu.AddMenu( transformMoveSubMenu, orientCondition, 200 );
365
366 transformMoveSubMenu->AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
367 transformMoveSubMenu->AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
368 transformMoveSubMenu->AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
369 transformMoveSubMenu->AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
370
371 {
372 CONDITIONAL_MENU *attribMoveSubMenu = new CONDITIONAL_MENU( moveTool );
373 attribMoveSubMenu->SetTitle( _( "Attributes" ) );
374 moveMenu.AddMenu( attribMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ), 200 );
375
376 {
377 CONDITIONAL_MENU *attribSimMoveSubMenu = new CONDITIONAL_MENU( moveTool );
378 attribSimMoveSubMenu->SetTitle( _( "Simulation" ) );
379 attribMoveSubMenu->AddMenu( attribSimMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
380 attribSimMoveSubMenu->AddItem( EE_ACTIONS::setExcludeFromSimulation,
382 attribSimMoveSubMenu->AddItem( EE_ACTIONS::unsetExcludeFromSimulation,
386 }
387
388 {
389 CONDITIONAL_MENU *attribBOMMoveSubMenu = new CONDITIONAL_MENU( moveTool );
390 attribBOMMoveSubMenu->SetTitle( _( "Bill of Materials" ) );
391 attribMoveSubMenu->AddMenu( attribBOMMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
392 attribBOMMoveSubMenu->AddItem( EE_ACTIONS::setExcludeFromBOM, E_C::ShowAlways );
395 }
396
397 {
398 CONDITIONAL_MENU *attribBoardMoveSubMenu = new CONDITIONAL_MENU( moveTool );
399 attribBoardMoveSubMenu->SetTitle( _( "Exclude from board" ) );
400 attribMoveSubMenu->AddMenu( attribBoardMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
401 attribBoardMoveSubMenu->AddItem( EE_ACTIONS::setExcludeFromBoard,
403 attribBoardMoveSubMenu->AddItem( EE_ACTIONS::unsetExcludeFromBoard,
405 attribBoardMoveSubMenu->AddItem( EE_ACTIONS::toggleExcludeFromBoard,
407 }
408
409 {
410 CONDITIONAL_MENU *attribDNPMoveSubMenu = new CONDITIONAL_MENU( moveTool );
411 attribDNPMoveSubMenu->SetTitle( _( "Do not populate" ) );
412 attribMoveSubMenu->AddMenu( attribDNPMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
413 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::setDNP, E_C::ShowAlways );
414 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::unsetDNP, E_C::ShowAlways );
415 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::toggleDNP, E_C::ShowAlways );
416 }
417 }
419
420 moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
421
422 CONDITIONAL_MENU* editMoveItemSubMenu = new CONDITIONAL_MENU(moveTool);
423 editMoveItemSubMenu->SetTitle( _( "Edit Main Fields" ) );
424 editMoveItemSubMenu->SetIcon( BITMAPS::right );
425 moveMenu.AddMenu( editMoveItemSubMenu, E_C::SingleSymbol );
426
427 editMoveItemSubMenu->AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol );
428 editMoveItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol );
429 editMoveItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol );
430
431 std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
432 symUnitMenu->SetTool( this );
433 m_menu.RegisterSubMenu( symUnitMenu );
434 moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
435
436 moveMenu.AddSeparator();
440 moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
441 }
442
443 //
444 // Add editing actions to the drawing tool menu
445 //
446 CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
447
448 drawMenu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 );
449 drawMenu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 );
450
451 drawMenu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 );
452 drawMenu.AddSeparator( sheetSelection && EE_CONDITIONS::Idle, 1 );
453
454 CONDITIONAL_MENU* transformDrawSubMenu = new CONDITIONAL_MENU( drawingTools );
455 transformDrawSubMenu->SetTitle( _( "Transform Selection" ) );
456 drawMenu.AddMenu( transformDrawSubMenu, orientCondition, 200 );
457
458 transformDrawSubMenu->AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
459 transformDrawSubMenu->AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
460 transformDrawSubMenu->AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
461 transformDrawSubMenu->AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
462
463 {
464 CONDITIONAL_MENU *attribMoveSubMenu = new CONDITIONAL_MENU( moveTool );
465 attribMoveSubMenu->SetTitle( _( "Attributes" ) );
466 drawMenu.AddMenu( attribMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ), 200 );
467
468 {
469 CONDITIONAL_MENU *attribSimMoveSubMenu = new CONDITIONAL_MENU( moveTool );
470 attribSimMoveSubMenu->SetTitle( _( "Simulation" ) );
471 attribMoveSubMenu->AddMenu( attribSimMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
473 attribSimMoveSubMenu->AddItem( EE_ACTIONS::unsetExcludeFromSimulation,
477 }
478
479 {
480 CONDITIONAL_MENU *attribBOMMoveSubMenu = new CONDITIONAL_MENU( moveTool );
481 attribBOMMoveSubMenu->SetTitle( _( "Bill of Materials" ) );
482 attribMoveSubMenu->AddMenu( attribBOMMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
483 attribBOMMoveSubMenu->AddItem( EE_ACTIONS::setExcludeFromBOM, E_C::ShowAlways );
486 }
487
488 {
489 CONDITIONAL_MENU *attribBoardMoveSubMenu = new CONDITIONAL_MENU( moveTool );
490 attribBoardMoveSubMenu->SetTitle( _( "Exclude from board" ) );
491 attribMoveSubMenu->AddMenu( attribBoardMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
492 attribBoardMoveSubMenu->AddItem( EE_ACTIONS::setExcludeFromBoard, E_C::ShowAlways );
495 }
496
497 {
498 CONDITIONAL_MENU *attribDNPMoveSubMenu = new CONDITIONAL_MENU( moveTool );
499 attribDNPMoveSubMenu->SetTitle( _( "Do not populate" ) );
500 attribMoveSubMenu->AddMenu( attribDNPMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
501 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::setDNP, E_C::ShowAlways );
502 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::unsetDNP, E_C::ShowAlways );
503 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::toggleDNP, E_C::ShowAlways );
504 }
505 }
506
507 drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
508
509 CONDITIONAL_MENU* editDrawItemSubMenu = new CONDITIONAL_MENU( drawingTools );
510 editDrawItemSubMenu->SetTitle( _( "Edit Main Fields" ) );
511 editDrawItemSubMenu->SetIcon( BITMAPS::right );
512 drawMenu.AddMenu( editDrawItemSubMenu, E_C::SingleSymbol, 200 );
513
514 editDrawItemSubMenu->AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol, 200 );
515 editDrawItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
516 editDrawItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 );
517
518
519 drawMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 );
520
521 std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
522 symUnitMenu2->SetTool( drawingTools );
523 drawingTools->GetToolMenu().RegisterSubMenu( symUnitMenu2 );
524 drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
525
527
528 drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
529 drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
530 drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
531 drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
532 drawMenu.AddItem( EE_ACTIONS::toTextBox, anyTextTool && E_C::Idle, 200 );
533
534 //
535 // Add editing actions to the selection tool menu
536 //
538
539 CONDITIONAL_MENU* transformSelSubMenu = new CONDITIONAL_MENU( m_selectionTool );
540 transformSelSubMenu->SetTitle( _( "Transform Selection" ) );
541 selToolMenu.AddMenu( transformSelSubMenu, orientCondition, 200 );
542
543 transformSelSubMenu->AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
544 transformSelSubMenu->AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
545 transformSelSubMenu->AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
546 transformSelSubMenu->AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
547
548 {
549 CONDITIONAL_MENU *attribMoveSubMenu = new CONDITIONAL_MENU( moveTool );
550 attribMoveSubMenu->SetTitle( _( "Attributes" ) );
551 selToolMenu.AddMenu( attribMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ), 200 );
552
553 {
554 CONDITIONAL_MENU *attribSimMoveSubMenu = new CONDITIONAL_MENU( moveTool );
555 attribSimMoveSubMenu->SetTitle( _( "Simulation" ) );
556 attribMoveSubMenu->AddMenu( attribSimMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
558 attribSimMoveSubMenu->AddItem( EE_ACTIONS::unsetExcludeFromSimulation,
562 }
563
564 {
565 CONDITIONAL_MENU *attribBOMMoveSubMenu = new CONDITIONAL_MENU( moveTool );
566 attribBOMMoveSubMenu->SetTitle( _( "Bill of Materials" ) );
567 attribMoveSubMenu->AddMenu( attribBOMMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
568 attribBOMMoveSubMenu->AddItem( EE_ACTIONS::setExcludeFromBOM, E_C::ShowAlways );
571 }
572
573 {
574 CONDITIONAL_MENU *attribBoardMoveSubMenu = new CONDITIONAL_MENU( moveTool );
575 attribBoardMoveSubMenu->SetTitle( _( "Exclude from board" ) );
576 attribMoveSubMenu->AddMenu( attribBoardMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
577 attribBoardMoveSubMenu->AddItem( EE_ACTIONS::setExcludeFromBoard, E_C::ShowAlways );
580 }
581
582 {
583 CONDITIONAL_MENU *attribDNPMoveSubMenu = new CONDITIONAL_MENU( moveTool );
584 attribDNPMoveSubMenu->SetTitle( _( "Do not populate" ) );
585 attribMoveSubMenu->AddMenu( attribDNPMoveSubMenu, E_C::HasType( SCH_SYMBOL_T ) );
586 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::setDNP, E_C::ShowAlways );
587 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::unsetDNP, E_C::ShowAlways );
588 attribDNPMoveSubMenu->AddItem( EE_ACTIONS::toggleDNP, E_C::ShowAlways );
589 }
590 }
591
593 selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
594
595 CONDITIONAL_MENU* editSelItemSubMenu = new CONDITIONAL_MENU( m_selectionTool );
596 editSelItemSubMenu->SetTitle( _( "Edit Main Fields" ) );
597 editSelItemSubMenu->SetIcon( BITMAPS::right );
598 selToolMenu.AddMenu( editSelItemSubMenu, E_C::SingleSymbol, 200 );
599
600 editSelItemSubMenu->AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol, 200 );
601 editSelItemSubMenu->AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
602 editSelItemSubMenu->AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 );
603
604 selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 );
605
606 std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
607 symUnitMenu3->SetTool( m_selectionTool );
609 selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
610
616
617 CONDITIONAL_MENU* convertToSubMenu = new CONDITIONAL_MENU( m_selectionTool );
618 convertToSubMenu->SetTitle( _( "Change To" ) );
619 convertToSubMenu->SetIcon( BITMAPS::right );
620 selToolMenu.AddMenu( convertToSubMenu, toChangeCondition, 200 );
621
622 convertToSubMenu->AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
623 convertToSubMenu->AddItem( EE_ACTIONS::toCLabel, toCLabelCondition, 200 );
624 convertToSubMenu->AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
625 convertToSubMenu->AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
626 convertToSubMenu->AddItem( EE_ACTIONS::toText, toTextCondition, 200 );
627 convertToSubMenu->AddItem( EE_ACTIONS::toTextBox, toTextBoxCondition, 200 );
628
629 selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetHasUndefinedPins, 250 );
630
631 selToolMenu.AddSeparator( 300 );
632 selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
633 selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
634 selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
635 selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
636 selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 300 );
637 selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
638
639 selToolMenu.AddSeparator( 400 );
640 selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
641
642
643 return true;
644}
645
646
647const std::vector<KICAD_T> SCH_EDIT_TOOL::RotatableItems = {
665};
666
667
669{
670 bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
672
673 if( selection.GetSize() == 0 )
674 return 0;
675
676 SCH_ITEM* head = nullptr;
677 int principalItemCount = 0; // User-selected items (as opposed to connected wires)
678 VECTOR2I rotPoint;
679 bool moving = false;
680
681 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
682 {
683 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
684
685 if( item->HasFlag( SELECTED_BY_DRAG ) )
686 continue;
687
688 principalItemCount++;
689
690 if( !head )
691 head = item;
692 }
693
694 if( head && head->IsMoving() )
695 moving = true;
696
697 if( principalItemCount == 1 )
698 {
699 if( moving && selection.HasReferencePoint() )
700 rotPoint = selection.GetReferencePoint();
701 else if( head->IsConnectable() )
702 rotPoint = head->GetPosition();
703 else
705
706 if( !moving )
707 saveCopyInUndoList( head, UNDO_REDO::CHANGED );
708
709 switch( head->Type() )
710 {
711 case SCH_SYMBOL_T:
712 {
713 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( head );
714
715 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
716 symbol->Rotate( rotPoint );
717
720
721 break;
722 }
723
724 case SCH_TEXT_T:
725 case SCH_LABEL_T:
727 case SCH_HIER_LABEL_T:
729 {
730 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( head );
731 textItem->Rotate90( clockwise );
732 break;
733 }
734
735 case SCH_SHEET_PIN_T:
736 {
737 // Rotate pin within parent sheet
738 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( head );
739 SCH_SHEET* sheet = pin->GetParent();
740
741 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
742 pin->Rotate( sheet->GetBodyBoundingBox().GetCenter() );
743
744 break;
745 }
746
747 case SCH_LINE_T:
748 {
749 SCH_LINE* line = static_cast<SCH_LINE*>( head );
750
751 // Equal checks for both and neither. We need this because on undo
752 // the item will have both flags cleared, but will be selected, so it is possible
753 // for the user to get a selected line with neither endpoint selected. We
754 // set flags to make sure Rotate() works when we call it.
755 if( line->HasFlag( STARTPOINT ) == line->HasFlag( ENDPOINT ) )
756 {
757 line->SetFlags( STARTPOINT | ENDPOINT );
758
759 // When we allow off grid items, the rotPoint should be set to the midpoint
760 // of the line to allow rotation around the center, and the next if
761 // should become an else-if
762 }
763
764 if( line->HasFlag( STARTPOINT ) )
765 rotPoint = line->GetEndPoint();
766 else if( line->HasFlag( ENDPOINT ) )
767 rotPoint = line->GetStartPoint();
768 }
769
771 case SCH_JUNCTION_T:
774 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
775 head->Rotate( rotPoint );
776
777 break;
778
779 case SCH_FIELD_T:
780 {
781 SCH_FIELD* field = static_cast<SCH_FIELD*>( head );
782
783 if( field->GetTextAngle().IsHorizontal() )
785 else
787
788 // Now that we're moving a field, they're no longer autoplaced.
789 static_cast<SCH_ITEM*>( head->GetParent() )->ClearFieldsAutoplaced();
790
791 break;
792 }
793
794 case SCH_SHAPE_T:
795 case SCH_TEXTBOX_T:
796 for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
797 head->Rotate( rotPoint );
798
799 break;
800
801 case SCH_BITMAP_T:
802 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
803 head->Rotate( rotPoint );
804
805 // The bitmap is cached in Opengl: clear the cache to redraw
807 break;
808
809 case SCH_SHEET_T:
810 {
811 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( head );
813
814 // Rotate the sheet on itself. Sheets do not have an anchor point.
815 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
816 sheet->Rotate( rotPoint );
817
818 break;
819 }
820
821 default:
822 UNIMPLEMENTED_FOR( head->GetClass() );
823 }
824
825 m_frame->UpdateItem( head, false, true );
826 }
827 else
828 {
829 if( moving && selection.HasReferencePoint() )
830 rotPoint = selection.GetReferencePoint();
831 else
832 rotPoint = m_frame->GetNearestHalfGridPosition( selection.GetCenter() );
833 }
834
835 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
836 {
837 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
838
839 // We've already rotated the user selected item if there was only one. We're just
840 // here to rotate the ends of wires that were attached to it.
841 if( principalItemCount == 1 && !item->HasFlag( SELECTED_BY_DRAG ) )
842 continue;
843
844 if( !moving )
845 saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
846
847 for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
848 {
849 if( item->Type() == SCH_LINE_T )
850 {
851 SCH_LINE* line = (SCH_LINE*) item;
852
853 // If we are rotating more than one item, we do not have start/end
854 // points separately selected
855 if( item->HasFlag( STARTPOINT ) )
856 line->RotateStart( rotPoint );
857
858 if( item->HasFlag( ENDPOINT ) )
859 line->RotateEnd( rotPoint );
860 }
861 else if( item->Type() == SCH_SHEET_PIN_T )
862 {
863 if( item->GetParent()->IsSelected() )
864 {
865 // parent will rotate us
866 }
867 else
868 {
869 // rotate within parent
870 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
871 SCH_SHEET* sheet = pin->GetParent();
872
873 pin->Rotate( sheet->GetBodyBoundingBox().GetCenter() );
874 }
875 }
876 else if( item->Type() == SCH_FIELD_T )
877 {
878 if( item->GetParent()->IsSelected() )
879 {
880 // parent will rotate us
881 }
882 else
883 {
884 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
885
886 field->Rotate( rotPoint );
887
888 if( field->GetTextAngle().IsHorizontal() )
890 else
892
893 // Now that we're moving a field, they're no longer autoplaced.
894 static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
895 }
896 }
897 else
898 {
899 item->Rotate( rotPoint );
900 }
901 }
902
903 m_frame->UpdateItem( item, false, true );
904 updateItem( item, true );
905 }
906
908
909 if( moving )
910 {
912 }
913 else
914 {
915 EE_SELECTION selectionCopy = selection;
916
917 if( selection.IsHover() )
919
921 lwbTool->TrimOverLappingWires( &selectionCopy );
922 lwbTool->AddJunctionsIfNeeded( &selectionCopy );
923
926
927 m_frame->OnModify();
928 }
929
930 return 0;
931}
932
933
935{
937
938 if( selection.GetSize() == 0 )
939 return 0;
940
941 bool vertical = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) );
942 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
943 bool connections = false;
944 bool moving = item->IsMoving();
945
946 if( selection.GetSize() == 1 )
947 {
948 if( !moving )
949 saveCopyInUndoList( item, UNDO_REDO::CHANGED );
950
951 switch( item->Type() )
952 {
953 case SCH_SYMBOL_T:
954 {
955 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
956
957 if( vertical )
958 symbol->SetOrientation( SYM_MIRROR_X );
959 else
960 symbol->SetOrientation( SYM_MIRROR_Y );
961
962 symbol->ClearFieldsAutoplaced();
963 break;
964 }
965
966 case SCH_TEXT_T:
967 case SCH_LABEL_T:
969 case SCH_HIER_LABEL_T:
971 {
972 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
973 textItem->MirrorSpinStyle( !vertical );
974 break;
975 }
976
977 case SCH_SHEET_PIN_T:
978 {
979 // mirror within parent sheet
980 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
981 SCH_SHEET* sheet = pin->GetParent();
982
983 if( vertical )
984 pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
985 else
986 pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
987
988 break;
989 }
990
991 case SCH_FIELD_T:
992 {
993 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
994
995 if( vertical )
996 field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
997 else
998 field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) );
999
1000 // Now that we're re-justifying a field, they're no longer autoplaced.
1001 static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
1002
1003 break;
1004 }
1005
1006 case SCH_BITMAP_T:
1007 if( vertical )
1008 item->MirrorVertically( item->GetPosition().y );
1009 else
1010 item->MirrorHorizontally( item->GetPosition().x );
1011
1012 // The bitmap is cached in Opengl: clear the cache to redraw
1014 break;
1015
1016 case SCH_SHEET_T:
1017 {
1018 // Mirror the sheet on itself. Sheets do not have a anchor point.
1020
1021 if( vertical )
1022 item->MirrorVertically( mirrorPoint.y );
1023 else
1024 item->MirrorHorizontally( mirrorPoint.x );
1025
1026 break;
1027 }
1028
1029 default:
1030 if( vertical )
1031 item->MirrorVertically( item->GetPosition().y );
1032 else
1033 item->MirrorHorizontally( item->GetPosition().x );
1034
1035 break;
1036 }
1037
1038 connections = item->IsConnectable();
1039 m_frame->UpdateItem( item, false, true );
1040 }
1041 else if( selection.GetSize() > 1 )
1042 {
1043 VECTOR2I mirrorPoint = m_frame->GetNearestHalfGridPosition( selection.GetCenter() );
1044
1045 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
1046 {
1047 item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
1048
1049 if( !moving )
1050 saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
1051
1052 if( item->Type() == SCH_SHEET_PIN_T )
1053 {
1054 if( item->GetParent()->IsSelected() )
1055 {
1056 // parent will mirror us
1057 }
1058 else
1059 {
1060 // mirror within parent sheet
1061 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
1062 SCH_SHEET* sheet = pin->GetParent();
1063
1064 if( vertical )
1065 pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
1066 else
1067 pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
1068 }
1069 }
1070 else if( item->Type() == SCH_FIELD_T )
1071 {
1072 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
1073
1074 if( vertical )
1075 field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
1076 else
1077 field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) );
1078
1079 // Now that we're re-justifying a field, they're no longer autoplaced.
1080 static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
1081 }
1082 else
1083 {
1084 if( vertical )
1085 item->MirrorVertically( mirrorPoint.y );
1086 else
1087 item->MirrorHorizontally( mirrorPoint.x );
1088 }
1089
1090 connections |= item->IsConnectable();
1091 m_frame->UpdateItem( item, false, true );
1092 }
1093 }
1094
1096
1097 // Update R-Tree for modified items
1098 for( EDA_ITEM* selected : selection )
1099 updateItem( selected, true );
1100
1101 if( item->IsMoving() )
1102 {
1104 }
1105 else
1106 {
1107 EE_SELECTION selectionCopy = selection;
1108
1109 if( selection.IsHover() )
1111
1112 if( connections )
1113 {
1115 lwbTool->TrimOverLappingWires( &selectionCopy );
1116 lwbTool->AddJunctionsIfNeeded( &selectionCopy );
1117
1120 }
1121
1122 m_frame->OnModify();
1123 }
1124
1125 return 0;
1126}
1127
1128
1129const std::vector<KICAD_T> swappableItems = {
1131 SCH_TEXT_T,
1143};
1144
1145
1147{
1149 std::vector<EDA_ITEM*> sorted = selection.GetItemsSortedBySelectionOrder();
1150
1151 if( selection.Size() < 2 )
1152 return 0;
1153
1154 bool isMoving = selection.Front()->IsMoving();
1155 bool appendUndo = isMoving;
1156 bool connections = false;
1157
1158 SCH_SCREEN* screen = this->m_frame->GetScreen();
1159
1160 for( size_t i = 0; i < sorted.size() - 1; i++ )
1161 {
1162 SCH_ITEM* a = static_cast<SCH_ITEM*>( sorted[i] );
1163 SCH_ITEM* b = static_cast<SCH_ITEM*>( sorted[( i + 1 ) % sorted.size()] );
1164
1165 VECTOR2I aPos = a->GetPosition(), bPos = b->GetPosition();
1166 std::swap( aPos, bPos );
1167
1168 saveCopyInUndoList( a, UNDO_REDO::CHANGED, appendUndo );
1169 appendUndo = true;
1170 saveCopyInUndoList( b, UNDO_REDO::CHANGED, appendUndo );
1171
1172 a->SetPosition( aPos );
1173 b->SetPosition( bPos );
1174
1175 if( a->Type() == b->Type() )
1176 {
1177 switch( a->Type() )
1178 {
1179 case SCH_LABEL_T:
1180 case SCH_GLOBAL_LABEL_T:
1181 case SCH_HIER_LABEL_T:
1183 m_frame->AutoRotateItem( screen, a );
1184 m_frame->AutoRotateItem( screen, b );
1185 break;
1186 case SCH_SYMBOL_T:
1187 {
1188 SCH_SYMBOL* aSymbol = static_cast<SCH_SYMBOL*>( a );
1189 SCH_SYMBOL* bSymbol = static_cast<SCH_SYMBOL*>( b );
1190 int aOrient = aSymbol->GetOrientation(), bOrient = bSymbol->GetOrientation();
1191 std::swap( aOrient, bOrient );
1192 aSymbol->SetOrientation( aOrient );
1193 bSymbol->SetOrientation( bOrient );
1194 break;
1195 }
1196 default: break;
1197 }
1198 }
1199
1200 connections |= a->IsConnectable();
1201 connections |= b->IsConnectable();
1202 m_frame->UpdateItem( a, false, true );
1203 m_frame->UpdateItem( b, false, true );
1204 }
1205
1207
1208 // Update R-Tree for modified items
1209 for( EDA_ITEM* selected : selection )
1210 updateItem( selected, true );
1211
1212 if( isMoving )
1213 {
1215 }
1216 else
1217 {
1218 if( selection.IsHover() )
1220
1221 if( connections )
1223
1224 m_frame->OnModify();
1225 }
1226
1227 return 0;
1228}
1229
1230
1232{
1233 const std::vector<std::unique_ptr<SCH_ITEM>>& sourceItems = m_frame->GetRepeatItems();
1234
1235 if( sourceItems.empty() )
1236 return 0;
1237
1239
1240 bool appendUndo = false;
1241 EE_SELECTION newItems;
1242
1243 for( const std::unique_ptr<SCH_ITEM>& item : sourceItems )
1244 {
1245 SCH_ITEM* newItem = item->Duplicate();
1246 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1247
1248 if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( newItem ) )
1249 {
1250 // If incrementing tries to go below zero, tell user why the value is repeated
1251
1252 if( !label->IncrementLabel( cfg->m_Drawing.repeat_label_increment ) )
1253 m_frame->ShowInfoBarWarning( _( "Label value cannot go below zero" ), true );
1254 }
1255
1256 // If cloning a symbol then put into 'move' mode.
1257 if( newItem->Type() == SCH_SYMBOL_T )
1258 {
1259 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( true );
1260 newItem->Move( cursorPos - newItem->GetPosition() );
1261 }
1262 else
1263 {
1266 }
1267
1268 m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newItem );
1269 newItem->SetFlags( IS_NEW );
1270 m_frame->AddToScreen( newItem, m_frame->GetScreen() );
1271 m_frame->SaveCopyInUndoList( m_frame->GetScreen(), newItem, UNDO_REDO::NEWITEM, appendUndo );
1272 appendUndo = true;
1273
1274 if( newItem->Type() == SCH_SYMBOL_T )
1275 {
1277 SCHEMATIC_SETTINGS& projSettings = m_frame->Schematic().Settings();
1278 int annotateStartNum = projSettings.m_AnnotateStartNum;
1279
1280 if( annotate.automatic )
1281 {
1282 static_cast<SCH_SYMBOL*>( newItem )->ClearAnnotation( nullptr, false );
1283 NULL_REPORTER reporter;
1285 (ANNOTATE_ORDER_T) annotate.sort_order,
1286 (ANNOTATE_ALGO_T) annotate.method, true /* recursive */,
1287 annotateStartNum, false, false, reporter, appendUndo );
1288 }
1289
1291 }
1292
1293 newItems.Add( newItem );
1294
1295 newItem->ClearFlags();
1296 }
1297
1298 if( !newItems.Empty() )
1299 {
1301 lwbTool->TrimOverLappingWires( &newItems );
1302 lwbTool->AddJunctionsIfNeeded( &newItems );
1303
1306 }
1307
1309 m_frame->OnModify();
1310
1311 if( !newItems.Empty() )
1312 m_frame->SaveCopyForRepeatItem( static_cast<SCH_ITEM*>( newItems[0] ) );
1313
1314 for( size_t ii = 1; ii < newItems.GetSize(); ++ii )
1315 m_frame->AddCopyForRepeatItem( static_cast<SCH_ITEM*>( newItems[ii] ) );
1316
1317 return 0;
1318}
1319
1320
1321static std::vector<KICAD_T> deletableItems =
1322{
1325 SCH_LINE_T,
1329 SCH_TEXT_T,
1339 SCH_FIELD_T, // Will be hidden
1341};
1342
1343
1345{
1346 SCH_SCREEN* screen = m_frame->GetScreen();
1347 std::deque<EDA_ITEM*> items = m_selectionTool->RequestSelection( deletableItems ).GetItems();
1348 bool appendToUndo = false;
1349 std::vector<VECTOR2I> pts;
1350
1351 if( items.empty() )
1352 return 0;
1353
1354 // Don't leave a freed pointer in the selection
1356
1357 for( EDA_ITEM* item : items )
1358 item->ClearFlags( STRUCT_DELETED );
1359
1360 for( EDA_ITEM* item : items )
1361 {
1362 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
1363
1364 if( !sch_item )
1365 continue;
1366
1367 if( sch_item->IsConnectable() )
1368 {
1369 std::vector<VECTOR2I> tmp_pts = sch_item->GetConnectionPoints();
1370 pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
1371 }
1372
1373 if( sch_item->Type() == SCH_JUNCTION_T )
1374 {
1375 sch_item->SetFlags( STRUCT_DELETED );
1376 // clean up junctions at the end
1377 }
1378 else if( sch_item->Type() == SCH_SHEET_PIN_T )
1379 {
1380 SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
1381 SCH_SHEET* sheet = pin->GetParent();
1382
1383 if( !alg::contains( items, sheet ) )
1384 {
1385 pin->SetFlags( STRUCT_DELETED );
1386 saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
1387 appendToUndo = true;
1388
1389 updateItem( pin, false );
1390
1391 sheet->RemovePin( pin );
1392 }
1393 }
1394 else if( sch_item->Type() == SCH_FIELD_T )
1395 {
1396 saveCopyInUndoList( item, UNDO_REDO::CHANGED, appendToUndo );
1397 static_cast<SCH_FIELD*>( sch_item )->SetVisible( false );
1398 appendToUndo = true;
1399
1400 updateItem( sch_item, false );
1401 }
1402 else
1403 {
1404 sch_item->SetFlags( STRUCT_DELETED );
1405 saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
1406 appendToUndo = true;
1407
1408 updateItem( sch_item, false );
1409
1410 m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() );
1411
1412 if( sch_item->Type() == SCH_SHEET_T )
1414 }
1415 }
1416
1417 for( const VECTOR2I& point : pts )
1418 {
1419 SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
1420
1421 if( !junction )
1422 continue;
1423
1424 if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsExplicitJunction( point ) )
1425 m_frame->DeleteJunction( junction, appendToUndo );
1426 }
1427
1429
1431 m_frame->OnModify();
1432
1433 return 0;
1434}
1435
1436
1437#define HITTEST_THRESHOLD_PIXELS 5
1438
1439
1441{
1443
1445 m_pickerItem = nullptr;
1446
1447 // Deactivate other tools; particularly important if another PICKER is currently running
1448 Activate();
1449
1450 picker->SetCursor( KICURSOR::REMOVE );
1451 picker->SetSnapping( false );
1452
1453 picker->SetClickHandler(
1454 [this]( const VECTOR2D& aPosition ) -> bool
1455 {
1456 if( m_pickerItem )
1457 {
1459 selectionTool->UnbrightenItem( m_pickerItem );
1460 selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
1462 m_pickerItem = nullptr;
1463 }
1464
1465 return true;
1466 } );
1467
1468 picker->SetMotionHandler(
1469 [this]( const VECTOR2D& aPos )
1470 {
1471 EE_COLLECTOR collector;
1472 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1473 collector.Collect( m_frame->GetScreen(), deletableItems, aPos );
1474
1476 selectionTool->GuessSelectionCandidates( collector, aPos );
1477
1478 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
1479
1480 if( m_pickerItem != item )
1481 {
1482 if( m_pickerItem )
1483 selectionTool->UnbrightenItem( m_pickerItem );
1484
1485 m_pickerItem = item;
1486
1487 if( m_pickerItem )
1488 selectionTool->BrightenItem( m_pickerItem );
1489 }
1490 } );
1491
1492 picker->SetFinalizeHandler(
1493 [this]( const int& aFinalState )
1494 {
1495 if( m_pickerItem )
1496 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
1497
1498 // Wake the selection tool after exiting to ensure the cursor gets updated
1500 } );
1501
1502 m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
1503
1504 return 0;
1505}
1506
1507
1509{
1510 KICAD_T parentType = aField->GetParent() ? aField->GetParent()->Type() : SCHEMATIC_T;
1511 SCHEMATIC_COMMIT commit( m_toolMgr );
1512
1513 // Save old symbol in undo list if not already in edit, or moving.
1514 if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
1515 commit.Modify( aField, m_frame->GetScreen() );
1516
1517 if( parentType == SCH_SYMBOL_T && aField->GetId() == REFERENCE_FIELD )
1518 static_cast<SCH_ITEM*>( aField->GetParent() )->SetConnectivityDirty();
1519
1520 wxString caption;
1521
1522 // Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
1523 if( parentType == SCH_SYMBOL_T && aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
1524 {
1525 wxString translated_fieldname;
1526 translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(),
1527 DO_TRANSLATE );
1528 caption.Printf( _( "Edit %s Field" ), TitleCaps( translated_fieldname ) );
1529 }
1530 else if( parentType == SCH_SHEET_T && aField->GetId() < SHEET_MANDATORY_FIELDS )
1531 caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
1532 else
1533 caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
1534
1535 DIALOG_SCH_FIELD_PROPERTIES dlg( m_frame, caption, aField );
1536
1537 // The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
1538 if( dlg.ShowQuasiModal() != wxID_OK )
1539 return;
1540
1541 dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
1542
1543 if( m_frame->eeconfig()->m_AutoplaceFields.enable || parentType == SCH_SHEET_T )
1544 static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
1545
1546 if( !commit.Empty() )
1547 commit.Push( caption );
1548
1549 m_frame->UpdateItem( aField, false, true );
1550 m_frame->OnModify();
1551
1552 // This must go after OnModify() so that the connectivity graph will have been updated.
1554}
1555
1556
1558{
1559 EE_SELECTION sel;
1560
1561 if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1563 else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1565 else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1567
1568 if( sel.Size() != 1 )
1569 return 0;
1570
1571 bool clearSelection = sel.IsHover();
1572 EDA_ITEM* item = sel.Front();
1573
1574 if( item->Type() == SCH_SYMBOL_T )
1575 {
1576 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1577
1578 if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1580 else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1581 editFieldText( symbol->GetField( VALUE_FIELD ) );
1582 else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1584 }
1585 else if( item->Type() == SCH_FIELD_T )
1586 {
1587 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
1588
1589 editFieldText( field );
1590
1591 if( !field->IsVisible() )
1592 clearSelection = true;
1593 }
1594
1595 if( clearSelection )
1597
1598 return 0;
1599}
1600
1601
1603{
1605 SCHEMATIC_COMMIT commit( m_toolMgr );
1606 SCH_ITEM* head = static_cast<SCH_ITEM*>( selection.Front() );
1607 bool moving = head && head->IsMoving();
1608
1609 if( selection.Empty() )
1610 return 0;
1611
1612 std::vector<SCH_ITEM*> autoplaceItems;
1613
1614 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
1615 {
1616 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
1617
1618 if( item->IsType( EE_COLLECTOR::FieldOwners ) )
1619 autoplaceItems.push_back( item );
1620 else if( item->GetParent() && item->GetParent()->IsType( EE_COLLECTOR::FieldOwners ) )
1621 autoplaceItems.push_back( static_cast<SCH_ITEM*>( item->GetParent() ) );
1622 }
1623
1624 for( SCH_ITEM* sch_item : autoplaceItems )
1625 {
1626 if( !moving && !sch_item->IsNew() )
1627 commit.Modify( sch_item, m_frame->GetScreen() );
1628
1629 sch_item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1630
1631 updateItem( sch_item, true );
1632 }
1633
1635
1636 if( moving )
1637 {
1639 }
1640 else
1641 {
1642 if( !commit.Empty() )
1643 commit.Push( _( "Autoplace Fields" ) );
1644
1645 if( selection.IsHover() )
1647 }
1648
1649 return 0;
1650}
1651
1652
1654{
1655 SCH_SYMBOL* selectedSymbol = nullptr;
1657
1658 if( !selection.Empty() )
1659 selectedSymbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
1660
1662
1663 if( aEvent.IsAction( &EE_ACTIONS::changeSymbol )
1664 || aEvent.IsAction( &EE_ACTIONS::changeSymbols ) )
1665 {
1667 }
1668
1669 DIALOG_CHANGE_SYMBOLS dlg( m_frame, selectedSymbol, mode );
1670
1671 dlg.ShowQuasiModal();
1672
1673 return 0;
1674}
1675
1676
1678{
1680
1681 if( selection.Empty() )
1682 return 0;
1683
1684 SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
1685
1687 && symbol->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
1688 {
1689 return 0;
1690 }
1691
1694 {
1695 return 0;
1696 }
1697
1698 if( !symbol->IsNew() )
1699 saveCopyInUndoList( symbol, UNDO_REDO::CHANGED );
1700
1701 m_frame->ConvertPart( symbol );
1702
1703 if( symbol->IsNew() )
1705
1706 if( selection.IsHover() )
1708
1709 return 0;
1710}
1711
1712
1714{
1716 bool clearSelection = selection.IsHover();
1717
1718 if( selection.Empty() )
1719 {
1720 if( getView()->IsLayerVisible( LAYER_SCHEMATIC_DRAWINGSHEET ) )
1721 {
1723 VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1724
1725 if( ds && ds->HitTestDrawingSheetItems( getView(), cursorPos ) )
1727 }
1728
1729 return 0;
1730 }
1731
1732 EDA_ITEM* curr_item = selection.Front();
1733
1734 switch( curr_item->Type() )
1735 {
1736 case SCH_LINE_T:
1738 case SCH_JUNCTION_T:
1739 break;
1740
1741 default:
1742 if( selection.Size() > 1 )
1743 return 0;
1744
1745 break;
1746 }
1747
1748 switch( curr_item->Type() )
1749 {
1750 case SCH_SYMBOL_T:
1751 {
1752 int retval;
1753 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( curr_item );
1754
1755 // This needs to be scoped so the dialog destructor removes blocking status
1756 // before we launch the next dialog.
1757 {
1758 DIALOG_SYMBOL_PROPERTIES symbolPropsDialog( m_frame, symbol );
1759
1760 // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
1761 // frame. Therefore this dialog as a modal frame parent, MUST be run under
1762 // quasimodal mode for the quasimodal frame support to work. So don't use
1763 // the QUASIMODAL macros here.
1764 retval = symbolPropsDialog.ShowQuasiModal();
1765 }
1766
1767 if( retval == SYMBOL_PROPS_EDIT_OK )
1768 {
1771
1773 m_frame->OnModify();
1774 }
1775 else if( retval == SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL )
1776 {
1778 true );
1779
1780 if( wxWindow* blocking_win = editor->Kiway().GetBlockingDialog() )
1781 blocking_win->Close( true );
1782
1783 // The broken library symbol link indicator cannot be edited.
1784 if( symbol->IsMissingLibSymbol() )
1785 return 0;
1786
1787 editor->LoadSymbolFromSchematic( symbol );
1788
1789 editor->Show( true );
1790 editor->Raise();
1791 }
1792 else if( retval == SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL )
1793 {
1795 true );
1796
1797 if( wxWindow* blocking_win = editor->Kiway().GetBlockingDialog() )
1798 blocking_win->Close( true );
1799
1800 editor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbol->GetConvert() );
1801
1802 editor->Show( true );
1803 editor->Raise();
1804 }
1805 else if( retval == SYMBOL_PROPS_WANT_UPDATE_SYMBOL )
1806 {
1808 dlg.ShowQuasiModal();
1809 }
1810 else if( retval == SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL )
1811 {
1813 dlg.ShowQuasiModal();
1814 }
1815 }
1816 break;
1817
1818 case SCH_SHEET_T:
1819 {
1820 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( curr_item );
1821 bool doClearAnnotation;
1822 bool doRefresh = false;
1823
1824 // Keep track of existing sheet paths. EditSheet() can modify this list.
1825 // Note that we use the validity checking/repairing version here just to make sure
1826 // we've got a valid hierarchy to begin with.
1827 SCH_SHEET_LIST originalHierarchy( &m_frame->Schematic().Root(), true );
1828
1829 doRefresh = m_frame->EditSheetProperties( sheet, &m_frame->GetCurrentSheet(),
1830 &doClearAnnotation );
1831
1832 // If the sheet file is changed and new sheet contents are loaded then we have to
1833 // clear the annotations on the new content (as it may have been set from some other
1834 // sheet path reference)
1835 if( doClearAnnotation )
1836 {
1837 SCH_SCREENS screensList( &m_frame->Schematic().Root() );
1838
1839 // We clear annotation of new sheet paths here:
1840 screensList.ClearAnnotationOfNewSheetPaths( originalHierarchy );
1841
1842 // Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
1843 // path, but symbols managed by its sheet path must have their annotation cleared
1844 // because they are new:
1845 sheet->GetScreen()->ClearAnnotation( &m_frame->GetCurrentSheet(), false );
1846 }
1847
1848 if( doRefresh )
1849 {
1853 }
1854
1855 break;
1856 }
1857
1858 case SCH_SHEET_PIN_T:
1859 {
1860 SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( curr_item );
1862
1863 // QuasiModal required for help dialog
1864 if( dlg.ShowQuasiModal() == wxID_OK )
1865 {
1867 m_frame->OnModify();
1868 }
1869 }
1870 break;
1871
1872 case SCH_TEXT_T:
1873 case SCH_TEXTBOX_T:
1874 {
1875 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_ITEM*>( curr_item ) );
1876
1877 // QuasiModal required for syntax help and Scintilla auto-complete
1878 if( dlg.ShowQuasiModal() == wxID_OK )
1879 {
1881 m_frame->OnModify();
1882 }
1883 }
1884 break;
1885
1886 case SCH_LABEL_T:
1887 case SCH_GLOBAL_LABEL_T:
1888 case SCH_HIER_LABEL_T:
1890 {
1891 DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast<SCH_LABEL_BASE*>( curr_item ) );
1892
1893 // Must be quasi modal for syntax help
1894 if( dlg.ShowQuasiModal() == wxID_OK )
1895 {
1897 m_frame->OnModify();
1898 }
1899 }
1900 break;
1901
1902 case SCH_FIELD_T:
1903 {
1904 SCH_FIELD* field = static_cast<SCH_FIELD*>( curr_item );
1905
1906 editFieldText( field );
1907
1908 if( !field->IsVisible() )
1909 clearSelection = true;
1910 }
1911 break;
1912
1913 case SCH_SHAPE_T:
1914 {
1915 DIALOG_SHAPE_PROPERTIES dlg( m_frame, static_cast<SCH_SHAPE*>( curr_item ) );
1916
1917 if( dlg.ShowModal() == wxID_OK )
1918 {
1920 m_frame->OnModify();
1921 }
1922 }
1923 break;
1924
1925 case SCH_BITMAP_T:
1926 {
1927 SCH_BITMAP* bitmap = static_cast<SCH_BITMAP*>( curr_item );
1928 DIALOG_IMAGE_PROPERTIES dlg( m_frame, bitmap );
1929
1930 if( dlg.ShowModal() == wxID_OK )
1931 {
1932 // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1935 m_frame->OnModify();
1936 }
1937 }
1938 break;
1939
1940 case SCH_LINE_T:
1942 case SCH_JUNCTION_T:
1943 if( std::all_of( selection.Items().begin(), selection.Items().end(),
1944 [&]( const EDA_ITEM* item )
1945 {
1946 return item->Type() == SCH_LINE_T
1947 && static_cast<const SCH_LINE*>( item )->IsGraphicLine();
1948 } ) )
1949 {
1950 std::deque<SCH_LINE*> lines;
1951
1952 for( EDA_ITEM* selItem : selection.Items() )
1953 lines.push_back( static_cast<SCH_LINE*>( selItem ) );
1954
1955 DIALOG_LINE_PROPERTIES dlg( m_frame, lines );
1956
1957 if( dlg.ShowModal() == wxID_OK )
1958 {
1960 m_frame->OnModify();
1961 }
1962 }
1963 else if( std::all_of( selection.Items().begin(), selection.Items().end(),
1964 [&]( const EDA_ITEM* item )
1965 {
1966 return item->Type() == SCH_JUNCTION_T;
1967 } ) )
1968 {
1969 std::deque<SCH_JUNCTION*> junctions;
1970
1971 for( EDA_ITEM* selItem : selection.Items() )
1972 junctions.push_back( static_cast<SCH_JUNCTION*>( selItem ) );
1973
1974 DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
1975
1976 if( dlg.ShowModal() == wxID_OK )
1977 {
1979 m_frame->OnModify();
1980 }
1981 }
1982 else if( std::all_of( selection.Items().begin(), selection.Items().end(),
1983 [&]( const EDA_ITEM* item )
1984 {
1985 const SCH_ITEM* schItem = dynamic_cast<const SCH_ITEM*>( item );
1986
1987 wxCHECK( schItem, false );
1988
1989 return ( schItem->HasLineStroke() && schItem->IsConnectable() )
1990 || item->Type() == SCH_JUNCTION_T;
1991 } ) )
1992 {
1993 std::deque<SCH_ITEM*> items;
1994
1995 for( EDA_ITEM* selItem : selection.Items() )
1996 items.push_back( static_cast<SCH_ITEM*>( selItem ) );
1997
1998 DIALOG_WIRE_BUS_PROPERTIES dlg( m_frame, items );
1999
2000 if( dlg.ShowModal() == wxID_OK )
2001 {
2003 m_frame->OnModify();
2004 }
2005 }
2006 else
2007 {
2008 return 0;
2009 }
2010
2011 break;
2012
2013 case SCH_MARKER_T: // These items have no properties to edit
2014 case SCH_NO_CONNECT_T:
2015 break;
2016
2017 default: // Unexpected item
2018 wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + curr_item->GetClass() );
2019 }
2020
2021 updateItem( curr_item, true );
2022
2023 if( clearSelection )
2025
2026 return 0;
2027}
2028
2029
2031{
2032 KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
2034 SCH_TEXT_T,
2035 SCH_TEXTBOX_T } );
2036
2037 for( unsigned int i = 0; i < selection.GetSize(); ++i )
2038 {
2039 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( selection.GetItem( i ) );
2040
2041 if( item && item->Type() != convertTo )
2042 {
2043 bool selected = item->IsSelected();
2044 SCH_ITEM* newtext = nullptr;
2045 VECTOR2I position = item->GetPosition();
2046 wxString txt;
2047 wxString href;
2049 LABEL_FLAG_SHAPE shape = LABEL_FLAG_SHAPE::L_UNSPECIFIED;
2050
2051 switch( item->Type() )
2052 {
2053 case SCH_LABEL_T:
2054 case SCH_GLOBAL_LABEL_T:
2055 case SCH_HIER_LABEL_T:
2056 {
2057 SCH_TEXT* label = static_cast<SCH_LABEL_BASE*>( item );
2058
2059 txt = UnescapeString( label->GetText() );
2060 orientation = label->GetTextSpinStyle();
2061 shape = label->GetShape();
2062 href = label->GetHyperlink();
2063 break;
2064 }
2065
2067 {
2068 SCH_DIRECTIVE_LABEL* dirlabel = static_cast<SCH_DIRECTIVE_LABEL*>( item );
2069
2070 // a SCH_DIRECTIVE_LABEL has no text
2071 txt = _( "<empty>" );
2072
2073 orientation = dirlabel->GetTextSpinStyle();
2074 href = dirlabel->GetHyperlink();
2075 break;
2076 }
2077
2078 case SCH_TEXT_T:
2079 {
2080 SCH_TEXT* text = static_cast<SCH_TEXT*>( item );
2081
2082 txt = text->GetText();
2083 orientation = text->GetTextSpinStyle();
2084 href = text->GetHyperlink();
2085 break;
2086 }
2087
2088 case SCH_TEXTBOX_T:
2089 {
2090 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
2091 BOX2I bbox = textbox->GetBoundingBox();
2092
2093 bbox.Inflate( -textbox->GetTextMargin() );
2094
2095 if( convertTo == SCH_LABEL_T
2096 || convertTo == SCH_HIER_LABEL_T
2097 || convertTo == SCH_GLOBAL_LABEL_T )
2098 {
2099 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item );
2100 wxCHECK( text, 0 );
2101 int textSize = text->GetTextSize().y;
2102 bbox.Inflate( item->Schematic()->Settings().m_LabelSizeRatio * textSize );
2103 }
2104
2105 txt = textbox->GetText();
2106
2107 if( textbox->GetTextAngle().IsVertical() )
2108 {
2109 if( textbox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
2110 {
2111 orientation = TEXT_SPIN_STYLE::SPIN::BOTTOM;
2112 position = VECTOR2I( bbox.Centre().x, bbox.GetOrigin().y );
2113 }
2114 else
2115 {
2116 orientation = TEXT_SPIN_STYLE::SPIN::UP;
2117 position = VECTOR2I( bbox.Centre().x, bbox.GetEnd().y );
2118 }
2119 }
2120 else
2121 {
2122 if( textbox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
2123 {
2124 orientation = TEXT_SPIN_STYLE::SPIN::LEFT;
2125 position = VECTOR2I( bbox.GetEnd().x, bbox.Centre().y );
2126 }
2127 else
2128 {
2129 orientation = TEXT_SPIN_STYLE::SPIN::RIGHT;
2130 position = VECTOR2I( bbox.GetOrigin().x, bbox.Centre().y );
2131 }
2132 }
2133
2134 position = m_frame->GetNearestGridPosition( position );
2135 href = textbox->GetHyperlink();
2136 break;
2137 }
2138
2139 default:
2140 UNIMPLEMENTED_FOR( item->GetClass() );
2141 break;
2142 }
2143
2144 auto getValidNetname =
2145 []( const wxString& aText )
2146 {
2147 wxString local_txt = aText;
2148 local_txt.Replace( "\n", "_" );
2149 local_txt.Replace( "\r", "_" );
2150 local_txt.Replace( "\t", "_" );
2151
2152 // Bus groups can have spaces; bus vectors and signal names cannot
2153 if( !NET_SETTINGS::ParseBusGroup( aText, nullptr, nullptr ) )
2154 local_txt.Replace( " ", "_" );
2155
2156 // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
2157 local_txt = EscapeString( local_txt, CTX_NETNAME );
2158
2159 if( local_txt.IsEmpty() )
2160 return _( "<empty>" );
2161 else
2162 return local_txt;
2163 };
2164
2165 switch( convertTo )
2166 {
2167 case SCH_LABEL_T:
2168 {
2169 SCH_LABEL_BASE* new_label = new SCH_LABEL( position, getValidNetname( txt ) );
2170
2171 new_label->SetShape( shape );
2172 new_label->SetTextSpinStyle( orientation );
2173 new_label->SetHyperlink( href );
2174 newtext = new_label;
2175 break;
2176 }
2177
2178 case SCH_GLOBAL_LABEL_T:
2179 {
2180 SCH_LABEL_BASE* new_label = new SCH_GLOBALLABEL( position, getValidNetname( txt ) );
2181
2182 new_label->SetShape( shape );
2183 new_label->SetTextSpinStyle( orientation );
2184 new_label->SetHyperlink( href );
2185 newtext = new_label;
2186 break;
2187 }
2188
2189 case SCH_HIER_LABEL_T:
2190 {
2191 SCH_LABEL_BASE* new_label = new SCH_HIERLABEL( position, getValidNetname( txt ) );
2192
2193 new_label->SetShape( shape );
2194 new_label->SetTextSpinStyle( orientation );
2195 new_label->SetHyperlink( href );
2196 newtext = new_label;
2197 break;
2198 }
2199
2201 {
2202 SCH_LABEL_BASE* new_label = new SCH_DIRECTIVE_LABEL( position );
2203
2204 // A SCH_DIRECTIVE_LABEL usually has at least one field containing the net class
2205 // name. If we're copying from a text object assume the text is the netclass
2206 // name. Otherwise, we'll just copy the fields which will either have a netclass
2207 // or not.
2208 if( !dynamic_cast<SCH_LABEL_BASE*>( item ) )
2209 {
2210 SCH_FIELD netclass( position, 0, new_label, wxT( "Netclass" ) );
2211 netclass.SetText( txt );
2212 netclass.SetVisible( true );
2213 new_label->GetFields().push_back( netclass );
2214 }
2215
2216 new_label->SetShape( LABEL_FLAG_SHAPE::F_ROUND );
2217 new_label->SetTextSpinStyle( orientation );
2218 new_label->SetHyperlink( href );
2219 newtext = new_label;
2220 break;
2221 }
2222
2223 case SCH_TEXT_T:
2224 {
2225 SCH_TEXT* new_text = new SCH_TEXT( position, txt );
2226
2227 new_text->SetTextSpinStyle( orientation );
2228 new_text->SetHyperlink( href );
2229 newtext = new_text;
2230 break;
2231 }
2232
2233 case SCH_TEXTBOX_T:
2234 {
2235 SCH_TEXTBOX* new_textbox = new SCH_TEXTBOX( 0, FILL_T::NO_FILL, txt );
2236 BOX2I bbox = item->GetBoundingBox();
2237
2238 if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )
2239 bbox.Inflate( -label->GetLabelBoxExpansion() );
2240
2241 EDA_TEXT* textItem = dynamic_cast<EDA_TEXT*>( item );
2242 wxCHECK(textItem, 0 );
2243
2244 // Careful: GetTextMargin() is dependent on font size...
2245 new_textbox->SetTextSize( textItem->GetTextSize() );
2246
2247 int margin = new_textbox->GetTextMargin();
2248 bbox.Inflate( margin );
2249
2250 // Add 1/20 of the margin at the end to reduce line-breaking changes.
2251 int slop = margin / 20;
2252
2253 switch( orientation )
2254 {
2256 new_textbox->SetPosition( bbox.GetPosition() );
2257 new_textbox->SetEnd( bbox.GetEnd() + VECTOR2I( slop, 0 ) );
2258 break;
2259
2261 new_textbox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
2262 new_textbox->SetPosition( bbox.GetPosition() - VECTOR2I( slop, 0 ) );
2263 new_textbox->SetEnd( bbox.GetEnd() );
2264 break;
2265
2267 new_textbox->SetTextAngle( ANGLE_VERTICAL );
2268 new_textbox->SetPosition( bbox.GetPosition() - VECTOR2I( 0, slop ) );
2269 new_textbox->SetEnd( bbox.GetEnd() );
2270 break;
2271
2273 new_textbox->SetTextAngle( ANGLE_VERTICAL );
2274 new_textbox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
2275 new_textbox->SetPosition( bbox.GetPosition() );
2276 new_textbox->SetEnd( bbox.GetEnd() + VECTOR2I( 0, slop ) );
2277 break;
2278 }
2279
2280 new_textbox->SetHyperlink( href );
2281 newtext = new_textbox;
2282 break;
2283 }
2284
2285 default:
2286 UNIMPLEMENTED_FOR( wxString::Format( "%d.", convertTo ) );
2287 break;
2288 }
2289
2290 wxCHECK2( newtext, continue );
2291
2292 // Copy the old text item settings to the new one. Justifications are not copied
2293 // because they are not used in labels. Justifications will be set to default value
2294 // in the new text item type.
2295 //
2296 newtext->SetFlags( item->GetEditFlags() );
2297
2298 EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( item );
2299 EDA_TEXT* new_eda_text = dynamic_cast<EDA_TEXT*>( newtext );
2300
2301 wxCHECK2( eda_text && new_eda_text, continue );
2302
2303 new_eda_text->SetFont( eda_text->GetFont() );
2304 new_eda_text->SetTextSize( eda_text->GetTextSize() );
2305 new_eda_text->SetTextThickness( eda_text->GetTextThickness() );
2306 new_eda_text->SetItalic( eda_text->IsItalic() );
2307 new_eda_text->SetBold( eda_text->IsBold() );
2308
2309 newtext->AutoplaceFields( m_frame->GetScreen(), false );
2310
2311 SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item );
2312 SCH_LABEL_BASE* new_label = dynamic_cast<SCH_LABEL_BASE*>( newtext );
2313
2314 if( label && new_label )
2315 {
2316 new_label->AddFields( label->GetFields() );
2317
2318 // A SCH_GLOBALLABEL has a specific field, that has no meaning for
2319 // other labels, and expected to be the first field in list.
2320 // It is the first field in list for this kind of label
2321 // So remove field named "Intersheetrefs" if exists for other labels
2322 int min_idx = new_label->Type() == SCH_GLOBAL_LABEL_T ? 1 : 0;
2323 std::vector<SCH_FIELD>& fields = new_label->GetFields();
2324
2325 for( int ii = fields.size()-1; ii >= min_idx; ii-- )
2326 {
2327 if( fields[ii].GetCanonicalName() == wxT( "Intersheetrefs" ) )
2328 fields.erase( fields.begin() + ii );
2329 }
2330 }
2331
2332 if( selected )
2334
2335 if( !item->IsNew() )
2336 {
2337 saveCopyInUndoList( item, UNDO_REDO::DELETED, i != 0 );
2338 saveCopyInUndoList( newtext, UNDO_REDO::NEWITEM, true );
2339
2341 m_frame->AddToScreen( newtext, m_frame->GetScreen() );
2342 }
2343
2344 if( selected )
2345 m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
2346
2347 // Otherwise, pointer is owned by the undo stack
2348 if( item->IsNew() )
2349 delete item;
2350
2351 if( convertTo == SCH_TEXT_T || convertTo == SCH_TEXTBOX_T )
2352 {
2353 if( newtext->IsDangling() )
2354 getView()->Update( newtext, KIGFX::REPAINT );
2355 }
2356 else
2357 {
2359 }
2360
2361 m_frame->OnModify();
2362 }
2363 }
2364
2365 if( selection.IsHover() )
2367
2368 return 0;
2369}
2370
2371
2373{
2374 bool isSlice = aEvent.Matches( EE_ACTIONS::slice.MakeEvent() );
2377
2378 std::vector<SCH_LINE*> lines;
2379
2380 for( EDA_ITEM* item : selection )
2381 {
2382 if( SCH_LINE* line = dyn_cast<SCH_LINE*>( item ) )
2383 {
2384 if( !line->IsEndPoint( cursorPos ) )
2385 lines.push_back( line );
2386 }
2387 }
2388
2391
2392 for( SCH_LINE* line : lines )
2393 {
2394 SCH_LINE* newLine;
2395
2396 // We let the user select the break point if they're on a single line
2397 if( lines.size() == 1 && line->HitTest( cursorPos ) )
2398 m_frame->BreakSegment( line, cursorPos, &newLine );
2399 else
2400 m_frame->BreakSegment( line, line->GetMidPoint(), &newLine );
2401
2402 // Make sure both endpoints are deselected
2403 newLine->ClearFlags();
2404
2406 line->SetFlags( ENDPOINT );
2407
2408 // If we're a break, we want to drag both wires.
2409 // Side note: the drag/move tool only checks whether the first item is
2410 // new to determine if it should append undo or not, someday this should
2411 // be cleaned up and explictly controlled but for now the newLine
2412 // selection addition must be after the existing line.
2413 if( !isSlice )
2414 {
2415 m_selectionTool->AddItemToSel( newLine );
2416 newLine->SetFlags( STARTPOINT );
2417 }
2418 }
2419
2420 if( !lines.empty() )
2421 {
2423
2424 m_frame->OnModify();
2426
2427 m_toolMgr->RunAction( EE_ACTIONS::drag, false, true );
2428 }
2429
2430 return 0;
2431}
2432
2433
2435{
2437 SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
2438
2439 if( !sheet || !sheet->HasUndefinedPins() )
2440 return 0;
2441
2442 if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
2443 return 0;
2444
2445 saveCopyInUndoList( sheet, UNDO_REDO::CHANGED );
2446
2447 sheet->CleanupSheet();
2448
2449 updateItem( sheet, true );
2450 m_frame->OnModify();
2451
2452 if( selection.IsHover() )
2454
2455 return 0;
2456}
2457
2458
2460{
2462
2463 if( selection.GetSize() > 1 )
2464 return 0;
2465
2466 SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
2467
2469
2470 SCH_SCREEN* screen;
2471
2472 if( sheet )
2473 {
2474 // When changing the page number of a selected sheet, the current screen owns the sheet.
2475 screen = m_frame->GetScreen();
2476
2477 instance.push_back( sheet );
2478 }
2479 else
2480 {
2481 SCH_SHEET_PATH prevInstance = instance;
2482
2483 // When change the page number in the screen, the previous screen owns the sheet.
2484 if( prevInstance.size() )
2485 {
2486 prevInstance.pop_back();
2487 screen = prevInstance.LastScreen();
2488 }
2489 else
2490 {
2491 // The root sheet and root screen are effectively the same thing.
2492 screen = m_frame->GetScreen();
2493 }
2494
2495 sheet = m_frame->GetCurrentSheet().Last();
2496 }
2497
2498 wxString msg;
2499 wxString sheetPath = instance.PathHumanReadable( false );
2500 wxString pageNumber = instance.GetPageNumber();
2501
2502 msg.Printf( _( "Enter page number for sheet path%s" ),
2503 ( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath );
2504
2505 wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
2506
2507 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
2508
2509 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue() == instance.GetPageNumber() )
2510 return 0;
2511
2512 m_frame->SaveCopyInUndoList( screen, sheet, UNDO_REDO::CHANGED, false );
2513
2514 instance.SetPageNumber( dlg.GetValue() );
2515
2516 if( instance == m_frame->GetCurrentSheet() )
2517 {
2518 m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
2520 }
2521
2522 m_frame->OnModify();
2523
2524 return 0;
2525}
2526
2527
2529{
2530 wxString aFileName = *aEvent.Parameter<wxString*>();
2531 return ( m_frame->AddSheetAndUpdateDisplay( aFileName ) ? 0 : 1 );
2532}
2533
2534
2536{
2538 SCHEMATIC_COMMIT commit( m_toolMgr );
2539
2540 if( selection.Empty() )
2541 return 0;
2542
2543 for( EDA_ITEM* item : selection )
2544 {
2545 if( SCH_SYMBOL* sym = dyn_cast<SCH_SYMBOL*>( item ) )
2546 {
2547 commit.Modify( sym, m_frame->GetScreen() );
2548
2549 if( aEvent.IsAction( &EE_ACTIONS::setDNP ) )
2550 sym->SetDNP( true );
2551
2553 sym->SetExcludeFromSim( true );
2554
2556 sym->SetIncludeInBom( false );
2557
2559 sym->SetIncludeOnBoard( false );
2560 }
2561 }
2562
2563 commit.Push( _( "Set Attribute" ) );
2564 return 0;
2565}
2566
2567
2569{
2571 SCHEMATIC_COMMIT commit( m_toolMgr );
2572
2573 if( selection.Empty() )
2574 return 0;
2575
2576 for( EDA_ITEM* item : selection )
2577 {
2578 if( SCH_SYMBOL* sym = dyn_cast<SCH_SYMBOL*>( item ) )
2579 {
2580 commit.Modify( sym, m_frame->GetScreen() );
2581
2582 if( aEvent.IsAction( &EE_ACTIONS::unsetDNP ) )
2583 sym->SetDNP( false );
2584
2586 sym->SetExcludeFromSim( false );
2587
2589 sym->SetIncludeInBom( true );
2590
2592 sym->SetIncludeOnBoard( true );
2593 }
2594 }
2595
2596 commit.Push( _( "Clear Attribute" ) );
2597 return 0;
2598}
2599
2600
2602{
2604 SCHEMATIC_COMMIT commit( m_toolMgr );
2605
2606 if( selection.Empty() )
2607 return 0;
2608
2609 for( EDA_ITEM* item : selection )
2610 {
2611 if( SCH_SYMBOL* sym = dyn_cast<SCH_SYMBOL*>( item ) )
2612 {
2613 commit.Modify( sym, m_frame->GetScreen() );
2614
2615 if( aEvent.IsAction( &EE_ACTIONS::toggleDNP ) )
2616 sym->SetDNP( !sym->GetDNP() );
2617
2619 sym->SetExcludeFromSim( !sym->GetExcludeFromSim() );
2620
2622 sym->SetIncludeInBom( !sym->GetIncludeInBom() );
2623
2625 sym->SetIncludeOnBoard( !sym->GetIncludeOnBoard() );
2626 }
2627 }
2628
2629 commit.Push( _( "Toggle Attribute" ) );
2630 return 0;
2631
2632}
2633
2634
2636{
2642 Go( &SCH_EDIT_TOOL::Swap, EE_ACTIONS::swap.MakeEvent() );
2645
2664
2667
2680
2684
2686}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION pickerTool
Definition: actions.h:159
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION duplicate
Definition: actions.h:72
static TOOL_ACTION doDelete
Definition: actions.h:73
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION refreshPreview
Definition: actions.h:110
static TOOL_ACTION selectAll
Definition: actions.h:71
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
TOOL_MANAGER * getToolManager() const
void Clear()
Remove all the entries from the menu (as well as its title).
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 SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
const Vec & GetPosition() const
Definition: box2.h:185
const Vec & GetOrigin() const
Definition: box2.h:184
const Vec GetCenter() const
Definition: box2.h:196
const Vec GetEnd() const
Definition: box2.h:186
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
Vec Centre() const
Definition: box2.h:71
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
int m_Threshold
Definition: collector.h:234
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:104
bool Empty() const
Returns status of an item.
Definition: commit.h:143
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.
Dialog to update or change schematic library symbols.
Handle editing a single symbol field in the schematic editor.
void UpdateField(SCH_FIELD *aField, SCH_SHEET_PATH *aSheetPath)
int ShowQuasiModal()
Dialog used to edit SCH_SYMBOL objects in a schematic.
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const VECTOR2I &aPosition)
bool IsHorizontal() const
Definition: eda_angle.h:174
bool IsVertical() const
Definition: eda_angle.h:179
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 ...
VECTOR2I GetNearestGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize location to aPosition.
VECTOR2I GetNearestHalfGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:232
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:233
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:73
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:129
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:123
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:125
bool IsSelected() const
Definition: eda_item.h:106
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:165
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:127
virtual wxString GetClass() const =0
Return the class name.
bool IsMoving() const
Definition: eda_item.h:104
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:77
bool IsItalic() const
Definition: eda_text.h:138
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:128
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:92
virtual bool IsVisible() const
Definition: eda_text.h:144
KIFONT::FONT * GetFont() const
Definition: eda_text.h:196
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:260
wxString GetHyperlink() const
Definition: eda_text.h:333
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:157
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:229
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:197
void SetBold(bool aBold)
Definition: eda_text.cpp:221
bool IsBold() const
Definition: eda_text.h:141
void SetHyperlink(wxString aLink)
Definition: eda_text.h:334
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:160
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:359
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:175
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:205
int GetTextThickness() const
Definition: eda_text.h:120
void SetItalic(bool aItalic)
Definition: eda_text.cpp:213
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:343
VECTOR2I GetTextSize() const
Definition: eda_text.h:204
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:252
PANEL_ANNOTATE m_AnnotatePanel
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION mirrorV
Definition: ee_actions.h:126
static TOOL_ACTION unsetDNP
Definition: ee_actions.h:193
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION properties
Definition: ee_actions.h:129
static TOOL_ACTION toggleExcludeFromSimulation
Definition: ee_actions.h:188
static TOOL_ACTION unsetExcludeFromSimulation
Definition: ee_actions.h:187
static TOOL_ACTION setExcludeFromBoard
Definition: ee_actions.h:189
static TOOL_ACTION move
Definition: ee_actions.h:121
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:284
static TOOL_ACTION toGLabel
Definition: ee_actions.h:141
static TOOL_ACTION toggleExcludeFromBoard
Definition: ee_actions.h:191
static TOOL_ACTION setDNP
Definition: ee_actions.h:192
static TOOL_ACTION cleanupSheetPins
Definition: ee_actions.h:226
static TOOL_ACTION slice
Definition: ee_actions.h:145
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION drag
Definition: ee_actions.h:122
static TOOL_ACTION toText
Definition: ee_actions.h:142
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:88
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:136
static TOOL_ACTION toggleExcludeFromBOM
Definition: ee_actions.h:185
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:133
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:135
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:125
static TOOL_ACTION editValue
Definition: ee_actions.h:131
static TOOL_ACTION toLabel
Definition: ee_actions.h:138
static TOOL_ACTION toTextBox
Definition: ee_actions.h:143
static TOOL_ACTION breakWire
Definition: ee_actions.h:144
static TOOL_ACTION mirrorH
Definition: ee_actions.h:127
static TOOL_ACTION rotateCW
Definition: ee_actions.h:124
static TOOL_ACTION unsetExcludeFromBOM
Definition: ee_actions.h:184
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:172
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:60
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:290
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:90
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:164
static TOOL_ACTION changeSymbol
Definition: ee_actions.h:159
static TOOL_ACTION editFootprint
Definition: ee_actions.h:132
static TOOL_ACTION enterSheet
Definition: ee_actions.h:215
static TOOL_ACTION editReference
Definition: ee_actions.h:130
static TOOL_ACTION updateSymbols
Definition: ee_actions.h:158
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:93
static TOOL_ACTION setExcludeFromBOM
Definition: ee_actions.h:183
static TOOL_ACTION changeSymbols
Definition: ee_actions.h:157
static TOOL_ACTION setExcludeFromSimulation
Definition: ee_actions.h:186
static TOOL_ACTION unsetExcludeFromBoard
Definition: ee_actions.h:190
static TOOL_ACTION toCLabel
Definition: ee_actions.h:139
static TOOL_ACTION placeLabel
Definition: ee_actions.h:87
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:123
static TOOL_ACTION toHLabel
Definition: ee_actions.h:140
static TOOL_ACTION editTextAndGraphics
Definition: ee_actions.h:227
static TOOL_ACTION toggleDNP
Definition: ee_actions.h:194
static TOOL_ACTION swap
Definition: ee_actions.h:128
static TOOL_ACTION toggleDeMorgan
Definition: ee_actions.h:134
static TOOL_ACTION updateSymbol
Definition: ee_actions.h:160
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.
static const std::vector< KICAD_T > EditableItems
Definition: ee_collectors.h:42
static const std::vector< KICAD_T > FieldOwners
Definition: ee_collectors.h:44
static SELECTION_CONDITION SingleSymbol
static SELECTION_CONDITION SingleSymbolOrPower
static SELECTION_CONDITION SingleMultiUnitSymbol
static SELECTION_CONDITION MultipleSymbolsOrPower
bool empty() const
Definition: sch_rtree.h:176
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
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...
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
EE_SELECTION & GetSelection()
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:50
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:114
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false, bool aDirtyConnectivity=true)
Definition: ee_tool_base.h:145
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:202
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:66
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
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:102
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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:1608
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1401
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:410
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:432
@ BASE
Definition: lib_item.h:70
@ DEMORGAN
Definition: lib_item.h:70
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:720
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.
A singleton reporter that reports to nowhere.
Definition: reporter.h:223
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
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
These settings were stored in SCH_BASE_FRAME previously.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
SCH_SHEET & Root() const
Definition: schematic.h:102
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EESCHEMA_SETTINGS * eeconfig() const
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,...
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
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.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void ConvertPart(SCH_SYMBOL *aSymbol)
Definition: picksymbol.cpp:280
void DeleteJunction(SCH_ITEM *aItem, bool aAppend=false)
Removes a given junction and heals any wire segments under the junction.
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.
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.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
const std::vector< std::unique_ptr< SCH_ITEM > > & GetRepeatItems() const
Return the items which are to be repeated with the insert key.
void OnPageSettingsChange() override
Called when modifying the page settings.
bool AddSheetAndUpdateDisplay(const wxString aFullFileName)
Add a sheet file into the current sheet and updates display.
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 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.
const wxString & GetHighlightedConnection() const
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
void AddCopyForRepeatItem(const SCH_ITEM *aItem)
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.
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it)
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:195
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
int DeleteItemCursor(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
static const std::vector< KICAD_T > RotatableItems
Definition: sch_edit_tool.h:42
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:98
int EditField(const TOOL_EVENT &aEvent)
int EditPageNumber(const TOOL_EVENT &aEvent)
int DoDelete(const TOOL_EVENT &aEvent)
Run the deletion tool.
int UnsetAttribute(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int CleanupSheetPins(const TOOL_EVENT &aEvent)
void editFieldText(SCH_FIELD *aField)
Set up handlers for various events.
int Mirror(const TOOL_EVENT &aEvent)
int GlobalEdit(const TOOL_EVENT &aEvent)
Delete the selected items, or the item under the cursor.
int SetAttribute(const TOOL_EVENT &aEvent)
Modify Attributes.
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 ToggleAttribute(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)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_field.cpp:740
int GetId() const
Definition: sch_field.h:125
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:830
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual bool IsConnectable() const
Definition: sch_item.h:352
virtual void MirrorVertically(int aCenter)=0
Mirror item vertically about aCenter.
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:113
virtual bool IsDangling() const
Definition: sch_item.h:345
virtual void MirrorHorizontally(int aCenter)=0
Mirror item horizontally about aCenter.
void ClearFieldsAutoplaced()
Definition: sch_item.h:433
virtual void Move(const VECTOR2I &aMoveVector)=0
Move the item by aMoveVector to a new position.
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:448
virtual void Rotate(const VECTOR2I &aCenter)=0
Rotate the item around aCenter 90 degrees in the clockwise direction.
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:442
virtual bool HasLineStroke() const
Check if this schematic item has line stoke properties.
Definition: sch_item.h:461
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:367
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:94
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
void AddFields(const std::vector< SCH_FIELD > &aFields)
Definition: sch_label.h:103
void SetShape(LABEL_FLAG_SHAPE aShape) override
Definition: sch_label.h:74
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:90
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.
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
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
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:662
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the symbols inside new sheetpaths when a complex hierarchy is modified and n...
bool IsExplicitJunction(const VECTOR2I &aPosition) const
Indicates that a junction dot is necessary at the given location.
Definition: sch_screen.cpp:475
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
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:383
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear the annotation for the symbols in aSheetPath on the screen.
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
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:828
VECTOR2I GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
Definition: sch_sheet.cpp:693
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:555
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:379
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:441
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:110
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
Definition: sch_sheet.cpp:661
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_sheet.cpp:682
Schematic symbol object.
Definition: sch_symbol.h:81
int GetUnit() const
Definition: sch_symbol.h:231
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:891
int GetConvert() const
Definition: sch_symbol.h:273
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:239
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
int GetOrientation() const
Get the display symbol orientation.
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:178
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:195
int GetTextMargin() const
Definition: sch_textbox.cpp:68
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:175
TEXT_SPIN_STYLE GetTextSpinStyle() const
Definition: sch_text.h:157
virtual LABEL_FLAG_SHAPE GetShape() const
Definition: sch_text.h:159
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:193
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:184
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 SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
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 bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
void BrightenItem(EDA_ITEM *aItem)
int AddItemToSel(const TOOL_EVENT &aEvent)
void UnbrightenItem(EDA_ITEM *aItem)
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:42
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:75
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:120
const std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
Definition: selection.cpp:201
VECTOR2I GetReferencePoint() const
Definition: selection.h:252
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.cpp:93
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
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:213
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
bool HasReferencePoint() const
Definition: selection.h:247
The symbol library editor main window.
void update() override
Update menu state stub.
ACTION_MENU * create() const override
< Return an instance of this class. It has to be overridden in inheriting classes.
bool IsCurrentTool(const TOOL_ACTION &aAction) const
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Generic, UI-independent tool event.
Definition: tool_event.h:156
bool DisableGridSnapping() const
Definition: tool_event.h:344
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:365
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
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).
TOOL_MENU & GetToolMenu()
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void Activate()
Run the tool.
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
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
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:363
This file is part of the common library.
@ SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL
@ SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL
@ SYMBOL_PROPS_WANT_UPDATE_SYMBOL
@ SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL
@ SYMBOL_PROPS_EDIT_OK
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:426
#define IS_NEW
New item, just created.
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define STRUCT_DELETED
flag indication structures to be erased
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
#define HITTEST_THRESHOLD_PIXELS
@ ID_POPUP_SCH_SELECT_UNIT1
Definition: eeschema_id.h:95
@ ID_POPUP_SCH_SELECT_UNIT_CMP
Definition: eeschema_id.h:94
@ ID_POPUP_SCH_SELECT_UNIT_SYM_MAX
Definition: eeschema_id.h:98
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:386
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
see class PGM_BASE
@ SYM_MIRROR_Y
@ SYM_MIRROR_X
static std::vector< KICAD_T > deletableItems
const std::vector< KICAD_T > swappableItems
ANNOTATE_ORDER_T
Schematic annotation order options.
@ ANNOTATE_SELECTION
Annotate the selection.
ANNOTATE_ALGO_T
Schematic annotation type options.
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:49
LABEL_FLAG_SHAPE
Definition: sch_text.h:96
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
wxString UnescapeString(const wxString &aSource)
wxString TitleCaps(const wxString &aString)
Capitalize the first letter in each word.
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
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
#define DO_TRANSLATE
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ GR_TEXT_H_ALIGN_RIGHT
#define TO_VJUSTIFY(x)
#define TO_HJUSTIFY(x)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LINE_T
Definition: typeinfo.h:136
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:133
@ SCH_FIELD_LOCATE_REFERENCE_T
Definition: typeinfo.h:154
@ SCH_FIELD_LOCATE_FOOTPRINT_T
Definition: typeinfo.h:156
@ SCH_SYMBOL_T
Definition: typeinfo.h:146
@ SCH_FIELD_T
Definition: typeinfo.h:145
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:144
@ SCH_LABEL_T
Definition: typeinfo.h:141
@ SCH_FIELD_LOCATE_VALUE_T
Definition: typeinfo.h:155
@ SCH_SHEET_T
Definition: typeinfo.h:148
@ SCH_MARKER_T
Definition: typeinfo.h:131
@ SCH_SHAPE_T
Definition: typeinfo.h:137
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:143
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:135
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:165
@ SCHEMATIC_T
Definition: typeinfo.h:178
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:147
@ SCH_TEXT_T
Definition: typeinfo.h:140
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:134
@ SCH_BITMAP_T
Definition: typeinfo.h:138
@ SCH_TEXTBOX_T
Definition: typeinfo.h:139
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:142
@ SCH_JUNCTION_T
Definition: typeinfo.h:132
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
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588