KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_editor_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-2021 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
26
27#include <tool/picker_tool.h>
29#include <tools/ee_tool_utils.h>
33#include <clipboard.h>
34#include <ee_actions.h>
35#include <string_utils.h>
36#include <symbol_edit_frame.h>
37#include <sch_commit.h>
39#include <dialogs/dialog_text_properties.h>
44#include <view/view_controls.h>
45#include <richio.h>
47#include <sch_textbox.h>
48#include <wx/textdlg.h> // for wxTextEntryDialog
49#include <math/util.h> // for KiROUND
50
52 EE_TOOL_BASE( "eeschema.SymbolEditTool" ),
53 m_pickerItem( nullptr )
54{
55}
56
57
59{
61
64
65 wxASSERT_MSG( drawingTools, "eeschema.SymbolDrawing tool is not available" );
66
67 auto haveSymbolCondition =
68 [&]( const SELECTION& sel )
69 {
71 };
72
73 auto canEdit =
74 [&]( const SELECTION& sel )
75 {
77 return false;
78
79 if( m_frame->IsSymbolAlias() )
80 {
81 for( EDA_ITEM* item : sel )
82 {
83 if( item->Type() != SCH_FIELD_T )
84 return false;
85 }
86 }
87
88 return true;
89 };
90
91 const auto canCopyText = EE_CONDITIONS::OnlyTypes( {
98 } );
99
100 // Add edit actions to the move tool menu
101 if( moveTool )
102 {
103 CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
104
105 moveMenu.AddSeparator( 200 );
106 moveMenu.AddItem( EE_ACTIONS::rotateCCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
107 moveMenu.AddItem( EE_ACTIONS::rotateCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
108 moveMenu.AddItem( EE_ACTIONS::mirrorV, canEdit && EE_CONDITIONS::NotEmpty, 200 );
109 moveMenu.AddItem( EE_ACTIONS::mirrorH, canEdit && EE_CONDITIONS::NotEmpty, 200 );
110
111 moveMenu.AddItem( EE_ACTIONS::swap, canEdit && SELECTION_CONDITIONS::MoreThan( 1 ), 200);
112 moveMenu.AddItem( EE_ACTIONS::properties, canEdit && EE_CONDITIONS::Count( 1 ), 200 );
113
114 moveMenu.AddSeparator( 300 );
117 moveMenu.AddItem( ACTIONS::copyAsText, canCopyText && EE_CONDITIONS::IdleSelection, 300 );
118 moveMenu.AddItem( ACTIONS::duplicate, canEdit && EE_CONDITIONS::NotEmpty, 300 );
119 moveMenu.AddItem( ACTIONS::doDelete, canEdit && EE_CONDITIONS::NotEmpty, 200 );
120
121 moveMenu.AddSeparator( 400 );
122 moveMenu.AddItem( ACTIONS::selectAll, haveSymbolCondition, 400 );
123 moveMenu.AddItem( ACTIONS::unselectAll, haveSymbolCondition, 400 );
124 }
125
126 // Add editing actions to the drawing tool menu
127 CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
128
129 drawMenu.AddSeparator( 200 );
131 drawMenu.AddItem( EE_ACTIONS::rotateCW, canEdit && EE_CONDITIONS::IdleSelection, 200 );
132 drawMenu.AddItem( EE_ACTIONS::mirrorV, canEdit && EE_CONDITIONS::IdleSelection, 200 );
133 drawMenu.AddItem( EE_ACTIONS::mirrorH, canEdit && EE_CONDITIONS::IdleSelection, 200 );
134
135 drawMenu.AddItem( EE_ACTIONS::properties, canEdit && EE_CONDITIONS::Count( 1 ), 200 );
136
137 // Add editing actions to the selection tool menu
139
140 selToolMenu.AddItem( EE_ACTIONS::rotateCCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
141 selToolMenu.AddItem( EE_ACTIONS::rotateCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
142 selToolMenu.AddItem( EE_ACTIONS::mirrorV, canEdit && EE_CONDITIONS::NotEmpty, 200 );
143 selToolMenu.AddItem( EE_ACTIONS::mirrorH, canEdit && EE_CONDITIONS::NotEmpty, 200 );
144
145 selToolMenu.AddItem( EE_ACTIONS::swap, canEdit && SELECTION_CONDITIONS::MoreThan( 1 ), 200 );
146 selToolMenu.AddItem( EE_ACTIONS::properties, canEdit && EE_CONDITIONS::Count( 1 ), 200 );
147
148 selToolMenu.AddSeparator( 300 );
151 selToolMenu.AddItem( ACTIONS::copyAsText, canCopyText && EE_CONDITIONS::IdleSelection, 300 );
152 selToolMenu.AddItem( ACTIONS::paste, canEdit && EE_CONDITIONS::Idle, 300 );
153 selToolMenu.AddItem( ACTIONS::duplicate, canEdit && EE_CONDITIONS::NotEmpty, 300 );
154 selToolMenu.AddItem( ACTIONS::doDelete, canEdit && EE_CONDITIONS::NotEmpty, 300 );
155
156 selToolMenu.AddSeparator( 400 );
157 selToolMenu.AddItem( ACTIONS::selectAll, haveSymbolCondition, 400 );
158 selToolMenu.AddItem( ACTIONS::unselectAll, haveSymbolCondition, 400 );
159
160 return true;
161}
162
163
165{
167
168 if( selection.GetSize() == 0 )
169 return 0;
170
171 VECTOR2I rotPoint;
172 bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) );
173 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
174 SCH_COMMIT localCommit( m_toolMgr );
175 SCH_COMMIT* commit = dynamic_cast<SCH_COMMIT*>( aEvent.Commit() );
176
177 if( !commit )
178 commit = &localCommit;
179
180 if( !item->IsMoving() )
181 commit->Modify( m_frame->GetCurSymbol(), m_frame->GetScreen() );
182
183 if( selection.GetSize() == 1 )
184 rotPoint = item->GetPosition();
185 else
186 rotPoint = m_frame->GetNearestHalfGridPosition( selection.GetCenter() );
187
188 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
189 {
190 item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
191 item->Rotate( rotPoint, ccw );
192 m_frame->UpdateItem( item, false, true );
193 }
194
195 if( item->IsMoving() )
196 {
198 }
199 else
200 {
201 if( selection.IsHover() )
203
204 if( !localCommit.Empty() )
205 localCommit.Push( _( "Rotate" ) );
206 }
207
208 return 0;
209}
210
211
213{
215
216 if( selection.GetSize() == 0 )
217 return 0;
218
219 VECTOR2I mirrorPoint;
220 bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) );
221 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
222
223 if( !item->IsMoving() )
224 saveCopyInUndoList( m_frame->GetCurSymbol(), UNDO_REDO::LIBEDIT );
225
226 if( selection.GetSize() == 1 )
227 {
228 mirrorPoint = item->GetPosition();
229
230 switch( item->Type() )
231 {
232 case SCH_FIELD_T:
233 {
234 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
235
236 if( xAxis )
238 else
240
241 break;
242 }
243
244 default:
245 if( xAxis )
246 item->MirrorVertically( mirrorPoint.y );
247 else
248 item->MirrorHorizontally( mirrorPoint.x );
249
250 break;
251 }
252
253
254 m_frame->UpdateItem( item, false, true );
255 }
256 else
257 {
258 mirrorPoint = m_frame->GetNearestHalfGridPosition( selection.GetCenter() );
259
260 for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
261 {
262 item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
263
264 if( xAxis )
265 item->MirrorVertically( mirrorPoint.y );
266 else
267 item->MirrorHorizontally( mirrorPoint.x );
268
269 m_frame->UpdateItem( item, false, true );
270 }
271 }
272
273 if( item->IsMoving() )
274 {
276 }
277 else
278 {
279 if( selection.IsHover() )
281
282 m_frame->OnModify();
283 }
284
285 return 0;
286}
287
288
289const std::vector<KICAD_T> swappableItems = {
290 LIB_SYMBOL_T, // Allows swapping the anchor
291 SCH_PIN_T,
296};
297
298
300{
302 std::vector<EDA_ITEM*> sorted = selection.GetItemsSortedBySelectionOrder();
303
304 if( selection.Size() < 2 )
305 return 0;
306
307 EDA_ITEM* front = selection.Front();
308 bool isMoving = front->IsMoving();
309
310 // Save copy for undo if not in edit (edit command already handle the save copy)
311 if( front->GetEditFlags() == 0 )
312 saveCopyInUndoList( front->GetParent(), UNDO_REDO::LIBEDIT );
313
314 for( size_t i = 0; i < sorted.size() - 1; i++ )
315 {
316 SCH_ITEM* a = static_cast<SCH_ITEM*>( sorted[i] );
317 SCH_ITEM* b = static_cast<SCH_ITEM*>( sorted[( i + 1 ) % sorted.size()] );
318
319 VECTOR2I aPos = a->GetPosition(), bPos = b->GetPosition();
320 std::swap( aPos, bPos );
321
322 a->SetPosition( aPos );
323 b->SetPosition( bPos );
324
325 // Special case some common swaps
326 if( a->Type() == b->Type() )
327 {
328 switch( a->Type() )
329 {
330 case SCH_PIN_T:
331 {
332 SCH_PIN* aPin = static_cast<SCH_PIN*>( a );
333 SCH_PIN* bBpin = static_cast<SCH_PIN*>( b );
334
335 PIN_ORIENTATION aOrient = aPin->GetOrientation();
336 PIN_ORIENTATION bOrient = bBpin->GetOrientation();
337
338 aPin->SetOrientation( bOrient );
339 bBpin->SetOrientation( aOrient );
340
341 break;
342 }
343 default: break;
344 }
345 }
346
347 m_frame->UpdateItem( a, false, true );
348 m_frame->UpdateItem( b, false, true );
349 }
350
351 // Update R-Tree for modified items
352 for( EDA_ITEM* selected : selection )
353 updateItem( selected, true );
354
355 if( isMoving )
356 {
358 }
359 else
360 {
361 if( selection.IsHover() )
363
364 m_frame->OnModify();
365 }
366
367 return 0;
368}
369
370
371static std::vector<KICAD_T> nonFields =
372{
378};
379
380
382{
383 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
384 std::deque<EDA_ITEM*> items = m_selectionTool->RequestSelection().GetItems();
385 SCH_COMMIT commit( m_frame );
386
387 if( items.empty() )
388 return 0;
389
390 // Don't leave a freed pointer in the selection
392
393 commit.Modify( symbol, m_frame->GetScreen() );
394
395 std::set<SCH_ITEM*> toDelete;
396 int fieldsHidden = 0;
397 int fieldsAlreadyHidden = 0;
398
399 for( EDA_ITEM* item : items )
400 {
401 if( item->Type() == SCH_PIN_T )
402 {
403 SCH_PIN* curr_pin = static_cast<SCH_PIN*>( item );
404 VECTOR2I pos = curr_pin->GetPosition();
405
406 toDelete.insert( curr_pin );
407
408 // when pin editing is synchronized, pins in the same position, with the same name
409 // in different units are also removed. But only one pin per unit (matching)
410 if( m_frame->SynchronizePins() )
411 {
412 std::vector<bool> got_unit( symbol->GetUnitCount() + 1 );
413
414 got_unit[curr_pin->GetUnit()] = true;
415
416 for( SCH_PIN* pin : symbol->GetAllLibPins() )
417 {
418 if( got_unit[pin->GetUnit()] )
419 continue;
420
421 if( pin->GetPosition() != pos )
422 continue;
423
424 if( pin->GetBodyStyle() != curr_pin->GetBodyStyle() )
425 continue;
426
427 if( pin->GetType() != curr_pin->GetType() )
428 continue;
429
430 if( pin->GetName() != curr_pin->GetName() )
431 continue;
432
433 toDelete.insert( pin );
434 got_unit[pin->GetUnit()] = true;
435 }
436 }
437 }
438 else if( item->Type() == SCH_FIELD_T )
439 {
440 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
441
442 // Hide "deleted" fields
443 if( field->IsVisible() )
444 {
445 field->SetVisible( false );
446 fieldsHidden++;
447 }
448 else
449 {
450 fieldsAlreadyHidden++;
451 }
452 }
453 else if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item ) )
454 {
455 toDelete.insert( schItem );
456 }
457 }
458
459 for( SCH_ITEM* item : toDelete )
460 symbol->RemoveDrawItem( item );
461
462 if( toDelete.size() == 0 )
463 {
464 if( fieldsHidden == 1 )
465 commit.Push( _( "Hide Field" ) );
466 else if( fieldsHidden > 1 )
467 commit.Push( _( "Hide Fields" ) );
468 else if( fieldsAlreadyHidden > 0 )
469 m_frame->ShowInfoBarError( _( "Use the Symbol Properties dialog to remove fields." ) );
470 }
471 else
472 {
473 commit.Push( _( "Delete" ) );
474 }
475
477 return 0;
478}
479
480
481#define HITTEST_THRESHOLD_PIXELS 5
482
483
485{
487
489 m_pickerItem = nullptr;
490
491 // Deactivate other tools; particularly important if another PICKER is currently running
492 Activate();
493
494 picker->SetCursor( KICURSOR::REMOVE );
495
496 picker->SetClickHandler(
497 [this]( const VECTOR2D& aPosition ) -> bool
498 {
499 if( m_pickerItem )
500 {
502 selectionTool->UnbrightenItem( m_pickerItem );
503 selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
505 m_pickerItem = nullptr;
506 }
507
508 return true;
509 } );
510
511 picker->SetMotionHandler(
512 [this]( const VECTOR2D& aPos )
513 {
515 EE_COLLECTOR collector;
516
517 selectionTool->CollectHits( collector, aPos, nonFields );
518
519 // Remove unselectable items
520 for( int i = collector.GetCount() - 1; i >= 0; --i )
521 {
522 if( !selectionTool->Selectable( collector[ i ] ) )
523 collector.Remove( i );
524 }
525
526 if( collector.GetCount() > 1 )
527 selectionTool->GuessSelectionCandidates( collector, aPos );
528
529 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
530
531 if( m_pickerItem != item )
532 {
533 if( m_pickerItem )
534 selectionTool->UnbrightenItem( m_pickerItem );
535
536 m_pickerItem = item;
537
538 if( m_pickerItem )
539 selectionTool->BrightenItem( m_pickerItem );
540 }
541 } );
542
543 picker->SetFinalizeHandler(
544 [this]( const int& aFinalState )
545 {
546 if( m_pickerItem )
547 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
548
549 // Wake the selection tool after exiting to ensure the cursor gets updated
551 } );
552
554
555 return 0;
556}
557
558
560{
562
563 if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
564 {
565 if( m_frame->GetCurSymbol() )
567 }
568 else if( selection.Size() == 1 )
569 {
570 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
571
572 // Save copy for undo if not in edit (edit command already handle the save copy)
573 if( item->GetEditFlags() == 0 )
574 saveCopyInUndoList( item->GetParent(), UNDO_REDO::LIBEDIT );
575
576 switch( item->Type() )
577 {
578 case SCH_PIN_T:
580 pinTool->EditPinProperties( static_cast<SCH_PIN*>( item ) );
581
582 break;
583
584 case SCH_SHAPE_T:
585 editShapeProperties( static_cast<SCH_SHAPE*>( item ) );
586 break;
587
588 case SCH_TEXT_T:
589 editTextProperties( item );
590 break;
591
592 case SCH_TEXTBOX_T:
593 editTextBoxProperties( item );
594 break;
595
596 case SCH_FIELD_T:
597 editFieldProperties( static_cast<SCH_FIELD*>( item ) );
598 break;
599
600 default:
601 wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
602 break;
603 }
604 }
605
606 if( selection.IsHover() )
608
609 return 0;
610}
611
612
614{
615 DIALOG_SHAPE_PROPERTIES dlg( m_frame, aShape );
616
617 if( dlg.ShowModal() != wxID_OK )
618 return;
619
620 updateItem( aShape, true );
622 m_frame->OnModify();
623
626 drawingTools->SetDrawSpecificUnit( !dlg.GetApplyToAllUnits() );
627
628 std::vector<MSG_PANEL_ITEM> items;
629 aShape->GetMsgPanelInfo( m_frame, items );
630 m_frame->SetMsgPanel( items );
631}
632
633
635{
636 if ( aItem->Type() != SCH_TEXT_T )
637 return;
638
639 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXT*>( aItem ) );
640
641 if( dlg.ShowModal() != wxID_OK )
642 return;
643
644 updateItem( aItem, true );
646 m_frame->OnModify( );
647}
648
649
651{
652 if ( aItem->Type() != SCH_TEXTBOX_T )
653 return;
654
655 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( aItem ) );
656
657 if( dlg.ShowModal() != wxID_OK )
658 return;
659
660 updateItem( aItem, true );
662 m_frame->OnModify( );
663}
664
665
667{
668 if( aField == nullptr )
669 return;
670
671 wxString caption;
672
673 if( aField->IsMandatory() )
674 caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
675 else
676 caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
677
678 DIALOG_FIELD_PROPERTIES dlg( m_frame, caption, aField );
679
680 // The dialog may invoke a kiway player for footprint fields
681 // so we must use a quasimodal dialog.
682 if( dlg.ShowQuasiModal() != wxID_OK )
683 return;
684
685 wxString newFieldValue = EscapeString( dlg.GetText(), CTX_LIBID );
686 wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
687
688 SCH_COMMIT commit( m_toolMgr );
689 commit.Modify( aField, m_frame->GetScreen() );
690
691 dlg.UpdateField( aField );
692
693 commit.Push( caption );
694
697}
698
699
701{
702 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
703 bool partLocked = symbol->UnitsLocked();
704
707
709
710 // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
711 // frame. Therefore this dialog as a modal frame parent, MUST be run under
712 // quasimodal mode for the quasimodal frame support to work. So don't use
713 // the QUASIMODAL macros here.
714 if( dlg.ShowQuasiModal() != wxID_OK )
715 return;
716
717 m_frame->OnModify();
718
719 // if m_UnitSelectionLocked has changed, set some edit options or defaults
720 // to the best value
721 if( partLocked != symbol->UnitsLocked() )
722 {
724
725 // Enable synchronized pin edit mode for symbols with interchangeable units
726 m_frame->m_SyncPinEdit = !symbol->UnitsLocked();
727
728 // also set default edit options to the better value
729 // Usually if units are locked, graphic items are specific to each unit
730 // and if units are interchangeable, graphic items are common to units
731 tools->SetDrawSpecificUnit( symbol->UnitsLocked() );
732 }
733}
734
736 int& aSymbolLastPinNumber )
737{
738 if( !aNewPin->GetNumber().IsEmpty() )
739 {
740 // when duplicating a pin in symbol editor, assigning identical pin number
741 // to the old one does not makes any sense, so assign the next unassigned number to it
742 aSymbolLastPinNumber++;
743 aNewPin->SetNumber( wxString::Format( wxT( "%i" ), aSymbolLastPinNumber ) );
744 }
745}
746
748{
749 SCH_COMMIT commit( m_frame );
750 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
751
752 if( !symbol )
753 return 0;
754
755 commit.Modify( symbol );
756
758
759 DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, symbol );
760
761 if( dlg.ShowModal() == wxID_CANCEL )
762 return -1;
763
764 commit.Push( _( "Edit Pins" ) );
766
767 return 0;
768}
769
770
772{
773 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
774
775 if( !symbol )
776 return 0;
777
778 if( !symbol->IsAlias() )
779 {
780 m_frame->ShowInfoBarError( _( "Symbol is not derived from another symbol." ) );
781 }
782 else
783 {
785
786 if( dlg.ShowModal() == wxID_CANCEL )
787 return -1;
788 }
789
790 return 0;
791}
792
793
795{
796 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
797
798 if( !symbol )
799 return 0;
800
801 int unitid = m_frame->GetUnit();
802
803 if( unitid == 0 )
804 {
805 return -1;
806 }
807
808 wxString promptText = wxString::Format( _( "Enter display name for unit %s" ),
809 symbol->GetUnitReference( unitid ) );
810 wxString currentvalue;
811
812 if( symbol->HasUnitDisplayName( unitid ) )
813 {
814 currentvalue = symbol->GetUnitDisplayName( unitid );
815 }
816
817 wxTextEntryDialog dlg( m_frame, promptText, _( "Set Unit Display Name" ), currentvalue );
818
819 if( dlg.ShowModal() == wxID_OK )
820 {
821 saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT );
822 symbol->SetUnitDisplayName( unitid, dlg.GetValue() );
824 m_frame->OnModify();
825 }
826 else
827 {
828 return -1;
829 }
830
831 return 0;
832}
833
834
836{
838
839 // Nuke the selection for later rebuilding. This does *not* clear the flags on any items;
840 // it just clears the SELECTION's reference to them.
841 selTool->GetSelection().Clear();
842 {
844 }
845 selTool->RebuildSelection();
846
847 return 0;
848}
849
850
852{
854
855 // Nuke the selection for later rebuilding. This does *not* clear the flags on any items;
856 // it just clears the SELECTION's reference to them.
857 selTool->GetSelection().Clear();
858 {
860 }
861 selTool->RebuildSelection();
862
863 return 0;
864}
865
866
868{
869 int retVal = Copy( aEvent );
870
871 if( retVal == 0 )
872 retVal = DoDelete( aEvent );
873
874 return retVal;
875}
876
877
879{
880 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
882
883 if( !symbol || !selection.GetSize() )
884 return 0;
885
886 for( SCH_ITEM& item : symbol->GetDrawItems() )
887 {
888 if( item.Type() == SCH_FIELD_T )
889 continue;
890
891 wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
892
893 if( !item.IsSelected() )
894 item.SetFlags( STRUCT_DELETED );
895 }
896
897 LIB_SYMBOL* partCopy = new LIB_SYMBOL( *symbol );
898
899 STRING_FORMATTER formatter;
900 SCH_IO_KICAD_SEXPR::FormatLibSymbol( partCopy, formatter );
901
902 delete partCopy;
903
904 for( SCH_ITEM& item : symbol->GetDrawItems() )
906
907 if( SaveClipboard( formatter.GetString() ) )
908 return 0;
909 else
910 return -1;
911}
912
913
915{
917 EE_SELECTION& selection = selTool->RequestSelection();
918
919 if( selection.Empty() )
920 return 0;
921
922 wxString itemsAsText = GetSelectedItemsAsText( selection );
923
924 if( selection.IsHover() )
926
927 return SaveClipboard( itemsAsText.ToStdString() );
928}
929
930
932{
933 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
934 LIB_SYMBOL* newPart = nullptr;
935
936 if( !symbol || symbol->IsAlias() )
937 return 0;
938
939 std::string clipboardData = GetClipboardUTF8();
940
941 try
942 {
943 std::vector<LIB_SYMBOL*> newParts = SCH_IO_KICAD_SEXPR::ParseLibSymbols( clipboardData, "Clipboard" );
944
945 if( newParts.empty() || !newParts[0] )
946 return -1;
947
948 newPart = newParts[0];
949 }
950 catch( IO_ERROR& )
951 {
952 // If it's not a symbol then paste as text
953 newPart = new LIB_SYMBOL( "dummy_part" );
954 SCH_TEXT* newText = new SCH_TEXT( { 0, 0 }, clipboardData, LAYER_DEVICE );
955 newPart->AddDrawItem( newText );
956 }
957
958 SCH_COMMIT commit( m_toolMgr );
959
960 commit.Modify( symbol );
962
963 for( SCH_ITEM& item : symbol->GetDrawItems() )
964 item.ClearFlags( IS_NEW | IS_PASTED | SELECTED );
965
966 for( SCH_ITEM& item : newPart->GetDrawItems() )
967 {
968 if( item.Type() == SCH_FIELD_T )
969 continue;
970
971 SCH_ITEM* newItem = item.Duplicate();
972 newItem->SetParent( symbol );
973 newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
974
975 newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 );
976 newItem->SetBodyStyle( newItem->GetBodyStyle() ? m_frame->GetBodyStyle() : 0 );
977
978 symbol->AddDrawItem( newItem );
979 getView()->Add( newItem );
980 }
981
982 delete newPart;
983
985
987
988 if( !selection.Empty() )
989 {
990 selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
991
993 commit.Push( _( "Paste" ) );
994 else
995 commit.Revert();
996 }
997
998 return 0;
999}
1000
1001
1003{
1004 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
1006 SCH_COMMIT commit( m_toolMgr );
1007
1008 if( selection.GetSize() == 0 )
1009 return 0;
1010
1011 commit.Modify( symbol, m_frame->GetScreen() );
1012
1013 std::vector<EDA_ITEM*> oldItems;
1014 std::vector<EDA_ITEM*> newItems;
1015
1016 std::copy( selection.begin(), selection.end(), std::back_inserter( oldItems ) );
1017 std::sort( oldItems.begin(), oldItems.end(), []( EDA_ITEM* a, EDA_ITEM* b )
1018 {
1019 int cmp;
1020
1021 if( a->Type() != b->Type() )
1022 return a->Type() < b->Type();
1023
1024 // Create the new pins in the same order as the old pins
1025 if( a->Type() == SCH_PIN_T )
1026 {
1027 const wxString& aNum = static_cast<SCH_PIN*>( a )->GetNumber();
1028 const wxString& bNum = static_cast<SCH_PIN*>( b )->GetNumber();
1029
1030 cmp = StrNumCmp( aNum, bNum );
1031
1032 // If the pin numbers are not numeric, then just number them by their position
1033 // on the screen.
1034 if( aNum.IsNumber() && bNum.IsNumber() && cmp != 0 )
1035 return cmp < 0;
1036 }
1037
1039
1040 if( cmp != 0 )
1041 return cmp < 0;
1042
1043 return a->m_Uuid < b->m_Uuid;
1044 } );
1045
1046 for( EDA_ITEM* item : oldItems )
1047 {
1048 SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( item );
1049 SCH_ITEM* newItem = oldItem->Duplicate();
1050
1051 if( newItem->Type() == SCH_PIN_T )
1052 {
1053 SCH_PIN* newPin = static_cast<SCH_PIN*>( newItem );
1054
1055 if( !newPin->GetNumber().IsEmpty() )
1056 newPin->SetNumber( wxString::Format( wxT( "%i" ), symbol->GetMaxPinNumber() + 1 ) );
1057 }
1058
1059 oldItem->ClearFlags( IS_NEW | IS_PASTED | SELECTED );
1060 newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
1061 newItem->SetParent( symbol );
1062 newItems.push_back( newItem );
1063
1064 symbol->AddDrawItem( newItem );
1065 getView()->Add( newItem );
1066 }
1067
1068 m_toolMgr->RunAction( EE_ACTIONS::clearSelection );
1069 m_toolMgr->RunAction<EDA_ITEMS*>( EE_ACTIONS::addItemsToSel, &newItems );
1070
1071 selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
1072
1073 if( m_toolMgr->RunSynchronousAction( EE_ACTIONS::move, &commit ) )
1074 commit.Push( _( "Duplicate" ) );
1075 else
1076 commit.Revert();
1077
1078 return 0;
1079}
1080
1081
1083{
1084 // clang-format off
1092
1100
1106 // clang-format on
1107}
static TOOL_ACTION paste
Definition: actions.h:73
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION unselectAll
Definition: actions.h:76
static TOOL_ACTION copy
Definition: actions.h:71
static TOOL_ACTION pickerTool
Definition: actions.h:195
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:77
static TOOL_ACTION doDelete
Definition: actions.h:78
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:79
static TOOL_ACTION cut
Definition: actions.h:70
static TOOL_ACTION copyAsText
Definition: actions.h:72
static TOOL_ACTION refreshPreview
Definition: actions.h:140
static TOOL_ACTION selectAll
Definition: actions.h:75
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
bool Empty() const
Returns status of an item.
Definition: commit.h:144
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.
This class is setup in expectation of its children possibly using Kiway player so DIALOG_SHIM::ShowQu...
void UpdateField(SCH_FIELD *aField)
const wxString & GetText() const
int ShowQuasiModal()
Dialog to update or change schematic library symbols.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
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:89
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:243
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:244
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:133
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:129
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
EDA_ITEM * GetParent() const
Definition: eda_item.h:103
bool IsMoving() const
Definition: eda_item.h:108
virtual bool IsVisible() const
Definition: eda_text.h:170
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:306
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:183
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:275
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:186
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:298
static TOOL_ACTION mirrorV
Definition: ee_actions.h:130
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:45
static TOOL_ACTION properties
Definition: ee_actions.h:133
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:62
static TOOL_ACTION move
Definition: ee_actions.h:125
static TOOL_ACTION pinTable
Definition: ee_actions.h:160
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:55
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:129
static TOOL_ACTION mirrorH
Definition: ee_actions.h:131
static TOOL_ACTION rotateCW
Definition: ee_actions.h:128
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:159
static TOOL_ACTION setUnitDisplayName
Definition: ee_actions.h:226
static TOOL_ACTION updateSymbolFields
Definition: ee_actions.h:225
static TOOL_ACTION swap
Definition: ee_actions.h:132
bool Selectable(const EDA_ITEM *aItem, const VECTOR2I *aPos=nullptr, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
bool CollectHits(EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
Collect one or more items at a given point.
EE_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, bool aPromoteCellSelections=false)
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.
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
EE_SELECTION & GetSelection()
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
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:109
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false, bool aDirtyConnectivity=true)
Definition: ee_tool_base.h:143
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:200
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:64
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:317
Define a library symbol object.
Definition: lib_symbol.h:78
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition: lib_symbol.h:264
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:260
bool IsAlias() const
Definition: lib_symbol.h:195
std::vector< SCH_PIN * > GetAllLibPins() const
Return a list of pin pointers for all units / converts.
Definition: lib_symbol.cpp:842
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:499
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
Definition: lib_symbol.cpp:771
bool HasUnitDisplayName(int aUnit) override
Return true if the given unit aUnit has a display name defined.
Definition: lib_symbol.cpp:254
wxString GetUnitReference(int aUnit) override
Return an identifier for aUnit for symbols with units.
Definition: lib_symbol.cpp:248
int GetUnitCount() const override
void SetUnitDisplayName(int aUnit, const wxString &aName)
Set the user-defined display name for aUnit to aName for symbols with units.
Definition: lib_symbol.cpp:276
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:796
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:84
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:73
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:64
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:104
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:432
virtual void Revert() override
Definition: sch_commit.cpp:510
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
bool IsMandatory() const
Definition: sch_field.cpp:1507
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: sch_field.cpp:335
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1227
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
static std::vector< LIB_SYMBOL * > ParseLibSymbols(std::string &aSymbolText, std::string aSource, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
virtual void SetBodyStyle(int aBodyStyle)
Definition: sch_item.h:231
int GetBodyStyle() const
Definition: sch_item.h:232
virtual void MirrorHorizontally(int aCenter)
Mirror item horizontally about aCenter.
Definition: sch_item.h:343
int GetUnit() const
Definition: sch_item.h:229
virtual void Rotate(const VECTOR2I &aCenter, bool aRotateCCW)
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_item.h:359
virtual void SetUnit(int aUnit)
Definition: sch_item.h:228
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:176
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:131
virtual void MirrorVertically(int aCenter)
Mirror item vertically about aCenter.
Definition: sch_item.h:351
void SetNumber(const wxString &aNumber)
Definition: sch_pin.cpp:475
void SetOrientation(PIN_ORIENTATION aOrientation)
Definition: sch_pin.h:84
const wxString & GetName() const
Definition: sch_pin.cpp:354
PIN_ORIENTATION GetOrientation() const
Definition: sch_pin.cpp:246
VECTOR2I GetPosition() const override
Definition: sch_pin.cpp:238
const wxString & GetNumber() const
Definition: sch_pin.h:115
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:292
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: sch_shape.cpp:499
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool IdleSelection(const SELECTION &aSelection)
Test if all selected items are not being edited.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
void BrightenItem(EDA_ITEM *aItem)
int AddItemToSel(const TOOL_EVENT &aEvent)
void UnbrightenItem(EDA_ITEM *aItem)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:75
ITER end()
Definition: selection.h:75
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:121
ITER begin()
Definition: selection.h:74
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.cpp:93
bool IsHover() const
Definition: selection.h:84
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:100
EDA_ITEM * Front() const
Definition: selection.h:172
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:93
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
Definition: selection.cpp:265
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.cpp:180
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:436
const std::string & GetString()
Definition: richio.h:459
SYMBOL_EDITOR_DRAWING_TOOLS.
void SetDrawSpecificBodyStyle(bool aSpecific)
int Undo(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
void editTextBoxProperties(SCH_ITEM *aItem)
int PinTable(const TOOL_EVENT &aEvent)
int Copy(const TOOL_EVENT &aEvent)
int CopyAsText(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int Cut(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int Redo(const TOOL_EVENT &aEvent)
void editTextProperties(SCH_ITEM *aItem)
int Swap(const TOOL_EVENT &aEvent)
void editFieldProperties(SCH_FIELD *aField)
void handlePinDuplication(SCH_PIN *aOldPin, SCH_PIN *aNewPin, int &aSymbolLastPinNumber)
Set up handlers for various events.
void editShapeProperties(SCH_SHAPE *aShape)
int Duplicate(const TOOL_EVENT &aEvent)
int Mirror(const TOOL_EVENT &aEvent)
int InteractiveDelete(const TOOL_EVENT &aEvent)
int Rotate(const TOOL_EVENT &aEvent)
int Properties(const TOOL_EVENT &aEvent)
int SetUnitDisplayName(const TOOL_EVENT &aEvent)
int UpdateSymbolFields(const TOOL_EVENT &aEvent)
int DoDelete(const TOOL_EVENT &aEvent)
Delete the selected items, or the item under the cursor.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
int GetBodyStyle() const
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
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:218
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:167
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:384
COMMIT * Commit() const
Returns information about difference between current mouse cursor position and the place where draggi...
Definition: tool_event.h:275
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:82
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()
void Activate()
Run the tool.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
bool RunSynchronousAction(const TOOL_ACTION &aAction, COMMIT *aCommit, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:197
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
Definition: clipboard.cpp:31
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
Definition: clipboard.cpp:51
#define _(s)
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:536
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_NEW
New item, just created.
#define SELECTED
Item was manually selected by the user.
#define STRUCT_DELETED
flag indication structures to be erased
wxString GetSelectedItemsAsText(const SELECTION &aSel)
@ LAYER_DEVICE
Definition: layer_ids.h:371
PIN_ORIENTATION
The symbol library pin object orientations.
Definition: pin_type.h:78
const std::vector< KICAD_T > swappableItems
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_LIBID
Definition: string_utils.h:54
static std::vector< KICAD_T > nonFields
const std::vector< KICAD_T > swappableItems
constexpr GR_TEXT_H_ALIGN_T GetFlippedAlignment(GR_TEXT_H_ALIGN_T aAlign)
Get the reverse alignment: left-right are swapped, others are unchanged.
@ SCH_TABLE_T
Definition: typeinfo.h:165
@ LIB_SYMBOL_T
Definition: typeinfo.h:148
@ SCH_TABLECELL_T
Definition: typeinfo.h:166
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_SHAPE_T
Definition: typeinfo.h:149
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_TEXTBOX_T
Definition: typeinfo.h:152
@ SCH_PIN_T
Definition: typeinfo.h:153
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
Definition: vector2d.h:640