KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_editor_control.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 <pgm_base.h>
27#include <sch_painter.h>
28#include <tool/tool_manager.h>
29#include <tools/ee_actions.h>
31#include <symbol_edit_frame.h>
33#include <symbol_viewer_frame.h>
37#include <confirm.h>
38#include <wx/filedlg.h>
39#include "wx/generic/textdlgg.h"
40#include "string_utils.h"
41
43{
44 m_frame = getEditFrame<SCH_BASE_FRAME>();
47
49 {
50 CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
51 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
52
53 wxCHECK( editFrame, false );
54
55 auto libSelectedCondition =
56 [ editFrame ]( const SELECTION& aSel )
57 {
58 LIB_ID sel = editFrame->GetTreeLIBID();
59 return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
60 };
61 // The libInferredCondition allows you to do things like New Symbol and Paste with a
62 // symbol selected (in other words, when we know the library context even if the library
63 // itself isn't selected.
64 auto libInferredCondition =
65 [ editFrame ]( const SELECTION& aSel )
66 {
67 LIB_ID sel = editFrame->GetTreeLIBID();
68 return !sel.GetLibNickname().empty();
69 };
70 auto pinnedLibSelectedCondition =
71 [ editFrame ]( const SELECTION& aSel )
72 {
73 LIB_TREE_NODE* node = editFrame->GetCurrentTreeNode();
74 return node && node->m_Type == LIB_TREE_NODE::LIBRARY && node->m_Pinned;
75 };
76 auto unpinnedLibSelectedCondition =
77 [ editFrame ](const SELECTION& aSel )
78 {
79 LIB_TREE_NODE* node = editFrame->GetCurrentTreeNode();
80 return node && node->m_Type == LIB_TREE_NODE::LIBRARY && !node->m_Pinned;
81 };
82 auto symbolSelectedCondition =
83 [ editFrame ]( const SELECTION& aSel )
84 {
85 LIB_ID sel = editFrame->GetTargetLibId();
86 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
87 };
88 auto saveSymbolAsCondition =
89 [ editFrame ]( const SELECTION& aSel )
90 {
91 LIB_ID sel = editFrame->GetTargetLibId();
92 return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
93 };
94 auto multiSelectedCondition =
95 [ editFrame ]( const SELECTION& aSel )
96 {
97 return editFrame->GetTreeSelectionCount() > 1;
98 };
99
100 ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
101 ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
102
103 ctxMenu.AddSeparator();
104 ctxMenu.AddItem( EE_ACTIONS::newSymbol, libInferredCondition );
105 ctxMenu.AddItem( EE_ACTIONS::deriveFromExistingSymbol, symbolSelectedCondition );
106
107 ctxMenu.AddSeparator();
108 ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition || libInferredCondition );
109 ctxMenu.AddItem( EE_ACTIONS::saveLibraryAs, libSelectedCondition );
110 ctxMenu.AddItem( EE_ACTIONS::saveSymbolCopyAs, saveSymbolAsCondition );
111 ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition || libInferredCondition );
112
113 ctxMenu.AddSeparator();
114 ctxMenu.AddItem( EE_ACTIONS::cutSymbol, symbolSelectedCondition || multiSelectedCondition );
115 ctxMenu.AddItem( EE_ACTIONS::copySymbol, symbolSelectedCondition || multiSelectedCondition );
116 ctxMenu.AddItem( EE_ACTIONS::pasteSymbol, libInferredCondition );
117 ctxMenu.AddItem( EE_ACTIONS::duplicateSymbol, symbolSelectedCondition );
118 ctxMenu.AddItem( EE_ACTIONS::renameSymbol, symbolSelectedCondition );
119 ctxMenu.AddItem( EE_ACTIONS::deleteSymbol, symbolSelectedCondition || multiSelectedCondition );
120
121 ctxMenu.AddSeparator();
122 ctxMenu.AddItem( EE_ACTIONS::importSymbol, libInferredCondition );
123 ctxMenu.AddItem( EE_ACTIONS::exportSymbol, symbolSelectedCondition );
124
125 // If we've got nothing else to show, at least show a hide tree option
126 ctxMenu.AddItem( EE_ACTIONS::hideSymbolTree, !libInferredCondition );
127 }
128
129 return true;
130}
131
132
134{
135 bool createNew = aEvent.IsAction( &ACTIONS::newLibrary );
136
138 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->AddLibraryFile( createNew );
139
140 return 0;
141}
142
143
145{
146 wxString libFile = *aEvent.Parameter<wxString*>();
148 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->DdAddLibrary( libFile );
149
150 return 0;
151}
152
153
155{
157 {
158 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
159 int unit = 0;
160 LIB_ID partId = editFrame->GetTreeLIBID( &unit );
161
162 editFrame->LoadSymbol( partId.GetLibItemName(), partId.GetLibNickname(), unit );
163 }
164
165 return 0;
166}
167
168
170{
172 {
173 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
174
175 LIB_ID sel = editFrame->GetTreeLIBID();
176 const wxString& libName = sel.GetLibNickname();
177 wxString msg;
178
179 if( libName.IsEmpty() )
180 {
181 msg.Printf( _( "No symbol library selected." ) );
183 return 0;
184 }
185
186 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
187 {
188 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
190 return 0;
191 }
192
193 if( aEvent.IsAction( &EE_ACTIONS::newSymbol ) )
194 {
195 editFrame->CreateNewSymbol();
196 }
198 {
199 editFrame->CreateNewSymbol( sel.GetLibItemName() );
200 }
201 else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) )
202 {
203 editFrame->ImportSymbol();
204 }
205 }
206
207 return 0;
208}
209
210
212{
214 {
215 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
216
217 if( aEvt.IsAction( &EE_ACTIONS::save ) )
218 editFrame->Save();
219 else if( aEvt.IsAction( &EE_ACTIONS::saveLibraryAs ) )
220 editFrame->SaveLibraryAs();
221 else if( aEvt.IsAction( &EE_ACTIONS::saveSymbolCopyAs ) )
222 editFrame->SaveSymbolCopyAs();
223 else if( aEvt.IsAction( &EE_ACTIONS::saveAll ) )
224 editFrame->SaveAll();
225 }
226
227 return 0;
228}
229
230
232{
234 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->Revert();
235
236 return 0;
237}
238
239
241{
243 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->ExportSymbol();
244
245 return 0;
246}
247
248
250{
252 {
253 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
254
256 editFrame->CopySymbolToClipboard();
257
259 {
260 bool hasWritableLibs = false;
261 wxString msg;
262
263 for( LIB_ID& sel : editFrame->GetSelectedLibIds() )
264 {
265 const wxString& libName = sel.GetLibNickname();
266
267 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
268 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
269 else
270 hasWritableLibs = true;
271 }
272
273 if( !msg.IsEmpty() )
275
276 if( !hasWritableLibs )
277 return 0;
278
279 editFrame->DeleteSymbolFromLibrary();
280 }
281 }
282
283 return 0;
284}
285
286
288{
290 {
291 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
292 LIB_ID sel = editFrame->GetTargetLibId();
293 // DuplicateSymbol() is called to duplicate a symbol, or to paste a previously
294 // saved symbol in clipboard
295 bool isPasteAction = aEvent.IsAction( &EE_ACTIONS::pasteSymbol );
296 wxString msg;
297
298 if( !sel.IsValid() && !isPasteAction )
299 {
300 // When duplicating a symbol, a source symbol must exists.
301 msg.Printf( _( "No symbol selected" ) );
303 return 0;
304 }
305
306 const wxString& libName = sel.GetLibNickname();
307
308 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
309 {
310 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
312 return 0;
313 }
314
315 editFrame->DuplicateSymbol( isPasteAction );
316 }
317
318 return 0;
319}
320
321
322class RENAME_DIALOG : public wxTextEntryDialog
323{
324public:
325 RENAME_DIALOG( wxWindow* aParent, const wxString& aName,
326 std::function<bool( wxString newName )> aValidator ) :
327 wxTextEntryDialog( aParent, _( "New name:" ), _( "Change Symbol Name" ), aName ),
328 m_validator( std::move( aValidator ) )
329 { }
330
331 wxString GetSymbolName()
332 {
333 wxString name = EscapeString( m_textctrl->GetValue(), CTX_LIBID );
334 name.Trim( true ).Trim( false );
335 return name;
336 }
337
338protected:
340 {
341 return m_validator( GetSymbolName() );
342 }
343
344private:
345 std::function<bool( wxString newName )> m_validator;
346};
347
348
350{
352 {
353 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
354 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
355
356 LIB_ID libId = editFrame->GetTreeLIBID();
357 wxString libName = libId.GetLibNickname();
358 wxString symbolName = libId.GetLibItemName();
359 wxString msg;
360
361 if( !libMgr.LibraryExists( libName ) )
362 return 0;
363
364 RENAME_DIALOG dlg( m_frame, symbolName,
365 [&]( wxString newName )
366 {
367 if( newName.IsEmpty() )
368 {
369 wxMessageBox( _( "Symbol must have a name." ) );
370 return false;
371 }
372
373 if( libMgr.SymbolExists( newName, libName ) )
374 {
375 msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'." ),
376 newName, libName );
377
378 KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ),
379 wxOK | wxCANCEL | wxICON_WARNING );
380 errorDlg.SetOKLabel( _( "Overwrite" ) );
381
382 return errorDlg.ShowModal() == wxID_OK;
383 }
384
385 return true;
386 } );
387
388 if( dlg.ShowModal() != wxID_OK )
389 return 0; // canceled by user
390
391 wxString newName = dlg.GetSymbolName();
392 wxString oldName = symbolName;
393 LIB_SYMBOL* libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
394 bool isCurrentSymbol = editFrame->IsCurrentSymbol( libId );
395
396 if( !libSymbol )
397 return 0;
398
399 libSymbol->SetName( newName );
400
401 if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
402 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
403
404 libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
405 libMgr.SetSymbolModified( newName, libName );
406
407 if( isCurrentSymbol && editFrame->GetCurSymbol())
408 {
409 libSymbol = editFrame->GetCurSymbol();
410
411 libSymbol->SetName( newName );
412
413 if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
414 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
415
416 editFrame->RebuildView();
417 editFrame->OnModify();
418 editFrame->UpdateTitle();
419
420 // N.B. The view needs to be rebuilt first as the Symbol Properties change may
421 // invalidate the view pointers by rebuilting the field table
422 editFrame->UpdateMsgPanel();
423 }
424
425 wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( libId );
426 editFrame->UpdateLibraryTree( treeItem, libSymbol );
427 editFrame->FocusOnLibId( LIB_ID( libName, newName ) );
428 }
429
430 return 0;
431}
432
433
435{
438
440 {
443
444 SYMBOL_EDIT_FRAME* symbolEditor = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
445 symbolEditor->SetConvert( convert );
446
448 symbolEditor->RebuildView();
449 }
450 else if( m_frame->IsType( FRAME_SCH_VIEWER ) )
451 {
452 SYMBOL_VIEWER_FRAME* symbolViewer = static_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
453 symbolViewer->SetUnitAndConvert( symbolViewer->GetUnit(), convert );
454 }
455
456 return 0;
457}
458
459
461{
463 {
464 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
465 LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
466
467 if( currentNode && !currentNode->m_Pinned )
468 {
469 m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), true );
470
471 currentNode->m_Pinned = true;
472 editFrame->RegenerateLibraryTree();
473 }
474 }
475
476 return 0;
477}
478
479
481{
483 {
484 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
485 LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
486
487 if( currentNode && currentNode->m_Pinned )
488 {
489 m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), true );
490
491 currentNode->m_Pinned = false;
492 editFrame->RegenerateLibraryTree();
493 }
494 }
495
496 return 0;
497}
498
499
501{
503 {
504 wxCommandEvent dummy;
505 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->OnToggleSymbolTree( dummy );
506 }
507
508 return 0;
509}
510
511
513{
515 getEditFrame<SYMBOL_EDIT_FRAME>()->ToggleProperties();
516
517 return 0;
518}
519
520
522{
524 renderSettings->m_ShowPinsElectricalType = !renderSettings->m_ShowPinsElectricalType;
525
526 // Update canvas
529
530 return 0;
531}
532
533
535{
537 renderSettings->m_ShowPinNumbers = !renderSettings->m_ShowPinNumbers;
538
539 // Update canvas
542
543 return 0;
544}
545
546
548{
549 if( !m_isSymbolEditor )
550 return 0;
551
552 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
553 editFrame->m_SyncPinEdit = !editFrame->m_SyncPinEdit;
554
555 return 0;
556}
557
558
560{
561 if( !m_isSymbolEditor )
562 return 0;
563
564 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
565 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
566
567 if( !symbol )
568 {
569 wxMessageBox( _( "No symbol to export" ) );
570 return 0;
571 }
572
573 wxFileName fn( symbol->GetName() );
574 fn.SetExt( "png" );
575
576 wxString projectPath = wxPathOnly( m_frame->Prj().GetProjectFullName() );
577
578 wxFileDialog dlg( editFrame, _( "Export View as PNG" ), projectPath, fn.GetFullName(),
579 PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
580
581 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
582 {
583 // calling wxYield is mandatory under Linux, after closing the file selector dialog
584 // to refresh the screen before creating the PNG or JPEG image from screen
585 wxYield();
586
587 if( !editFrame->SaveCanvasImageToFile( dlg.GetPath(), BITMAP_TYPE::PNG ) )
588 {
589 wxMessageBox( wxString::Format( _( "Can't save file '%s'." ), dlg.GetPath() ) );
590 }
591 }
592
593 return 0;
594}
595
596
598{
599 if( !m_isSymbolEditor )
600 return 0;
601
602 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
603 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
604
605 if( !symbol )
606 {
607 wxMessageBox( _( "No symbol to export" ) );
608 return 0;
609 }
610
611 wxFileName fn( symbol->GetName() );
612 fn.SetExt( SVGFileExtension );
613
614 wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
615
616 wxString fullFileName = wxFileSelector( _( "SVG File Name" ), pro_dir, fn.GetFullName(),
617 SVGFileExtension, SVGFileWildcard(), wxFD_SAVE,
618 m_frame );
619
620 if( !fullFileName.IsEmpty() )
621 {
622 PAGE_INFO pageSave = editFrame->GetScreen()->GetPageSettings();
623 PAGE_INFO pageTemp = pageSave;
624
625 BOX2I symbolBBox = symbol->GetUnitBoundingBox( editFrame->GetUnit(),
626 editFrame->GetConvert(), false );
627
628 // Add a small margin (10% of size)to the plot bounding box
629 symbolBBox.Inflate( symbolBBox.GetSize().x * 0.1, symbolBBox.GetSize().y * 0.1 );
630
631 pageTemp.SetWidthMils( schIUScale.IUToMils( symbolBBox.GetSize().x ) );
632 pageTemp.SetHeightMils( schIUScale.IUToMils( symbolBBox.GetSize().y ) );
633
634 // Add an offet to plot the symbol centered on the page.
635 VECTOR2I plot_offset = symbolBBox.GetOrigin();
636
637 editFrame->GetScreen()->SetPageSettings( pageTemp );
638 editFrame->SVGPlotSymbol( fullFileName, -plot_offset );
639 editFrame->GetScreen()->SetPageSettings( pageSave );
640 }
641
642 return 0;
643}
644
645
647{
648 LIB_SYMBOL* libSymbol = nullptr;
649 LIB_ID libId;
650 int unit, convert;
651
652 if( m_isSymbolEditor )
653 {
654 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
655
656 libSymbol = editFrame->GetCurSymbol();
657 unit = editFrame->GetUnit();
658 convert = editFrame->GetConvert();
659
660 if( libSymbol )
661 libId = libSymbol->GetLibId();
662 }
663 else
664 {
665 SYMBOL_VIEWER_FRAME* viewerFrame = getEditFrame<SYMBOL_VIEWER_FRAME>();
666
667 libSymbol = viewerFrame->GetSelectedSymbol();
668 unit = viewerFrame->GetUnit();
669 convert = viewerFrame->GetConvert();
670
671 if( libSymbol )
672 libId = libSymbol->GetLibId();
673 }
674
675 if( libSymbol )
676 {
677 SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH, false );
678
679 if( !schframe ) // happens when the schematic editor is not active (or closed)
680 {
681 DisplayErrorMessage( m_frame, _( "No schematic currently open." ) );
682 return 0;
683 }
684
685 wxWindow* blocking_dialog = schframe->Kiway().GetBlockingDialog();
686
687 if( blocking_dialog )
688 {
689 blocking_dialog->Raise();
690 wxBell();
691 return 0;
692 }
693
694 wxCHECK( libSymbol->GetLibId().IsValid(), 0 );
695
696 SCH_SYMBOL* symbol = new SCH_SYMBOL( *libSymbol, libId, &schframe->GetCurrentSheet(),
697 unit, convert );
698
699 symbol->SetParent( schframe->GetScreen() );
700
701 if( schframe->eeconfig()->m_AutoplaceFields.enable )
702 symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
703
704 schframe->Raise();
705 schframe->GetToolManager()->PostAction( EE_ACTIONS::placeSymbol, symbol );
706 }
707
708 return 0;
709}
710
711
713{
720
722
728
739
742
751}
const char * name
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION addLibrary
Definition: actions.h:49
static TOOL_ACTION pinLibrary
Definition: actions.h:116
static TOOL_ACTION saveAll
Definition: actions.h:54
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION unpinLibrary
Definition: actions.h:117
static TOOL_ACTION showProperties
Definition: actions.h:177
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
const Vec & GetOrigin() const
Definition: box2.h:184
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
const Vec & GetSize() const
Definition: box2.h:180
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 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...
bool IsType(FRAME_T aType) const
bool SaveCanvasImageToFile(const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:183
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION deleteSymbol
Definition: ee_actions.h:205
static TOOL_ACTION cutSymbol
Definition: ee_actions.h:206
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:79
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION duplicateSymbol
Definition: ee_actions.h:203
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:136
static TOOL_ACTION newSymbol
Definition: ee_actions.h:200
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:135
static TOOL_ACTION editSymbol
Definition: ee_actions.h:202
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:198
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:179
static TOOL_ACTION showPinNumbers
Definition: ee_actions.h:246
static TOOL_ACTION exportSymbolAsSVG
Definition: ee_actions.h:251
static TOOL_ACTION importSymbol
Definition: ee_actions.h:209
static TOOL_ACTION saveSymbolCopyAs
Definition: ee_actions.h:199
static TOOL_ACTION hideSymbolTree
Definition: ee_actions.h:248
static TOOL_ACTION copySymbol
Definition: ee_actions.h:207
static TOOL_ACTION renameSymbol
Definition: ee_actions.h:204
static TOOL_ACTION exportSymbol
Definition: ee_actions.h:210
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:239
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:247
static TOOL_ACTION exportSymbolView
Definition: ee_actions.h:250
static TOOL_ACTION deriveFromExistingSymbol
Definition: ee_actions.h:201
static TOOL_ACTION pasteSymbol
Definition: ee_actions.h:208
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:245
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:197
Store schematic specific render settings.
Definition: sch_painter.h:71
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1500
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
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
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:689
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
@ BASE
Definition: lib_item.h:77
@ DEMORGAN
Definition: lib_item.h:77
Symbol library management helper that is specific to the symbol library editor frame.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
Define a library symbol object.
Definition: lib_symbol.h:99
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
LIB_ID GetLibId() const override
Definition: lib_symbol.h:163
wxString GetName() const override
Definition: lib_symbol.h:160
const BOX2I GetUnitBoundingBox(int aUnit, int aConvert, bool aIgnoreHiddenFields=true) const
Get the bounding box for the symbol.
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:589
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
enum TYPE m_Type
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:58
void SetHeightMils(double aHeightInMils)
Definition: page_info.cpp:261
void SetWidthMils(double aWidthInMils)
Definition: page_info.cpp:247
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:137
void UnpinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:200
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:179
std::function< bool(wxString newName)> m_validator
bool TransferDataFromWindow() override
RENAME_DIALOG(wxWindow *aParent, const wxString &aName, std::function< bool(wxString newName)> aValidator)
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.
EESCHEMA_SETTINGS * eeconfig() const
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:131
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:132
Schematic symbol object.
Definition: sch_symbol.h:81
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
int ToggleSyncedPinsMode(const TOOL_EVENT &aEvent)
int OnDeMorgan(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvt)
int EditSymbol(const TOOL_EVENT &aEvent)
int ExportView(const TOOL_EVENT &aEvent)
int ShowElectricalTypes(const TOOL_EVENT &aEvent)
int RenameSymbol(const TOOL_EVENT &newName)
int DuplicateSymbol(const TOOL_EVENT &aEvent)
int UnpinLibrary(const TOOL_EVENT &aEvent)
int AddLibrary(const TOOL_EVENT &aEvent)
int AddSymbol(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int ExportSymbol(const TOOL_EVENT &aEvent)
void setTransitions() override
< Set up handlers for various events.
int ToggleProperties(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int ToggleSymbolTree(const TOOL_EVENT &aEvent)
int ExportSymbolAsSVG(const TOOL_EVENT &aEvent)
int ShowPinNumbers(const TOOL_EVENT &aEvent)
int DdAddLibrary(const TOOL_EVENT &aEvent)
int AddSymbolToSchematic(const TOOL_EVENT &aEvent)
int PinLibrary(const TOOL_EVENT &aEvent)
int CutCopyDelete(const TOOL_EVENT &aEvent)
The symbol library editor main window.
void SaveAll()
Save all modified symbols and libraries.
void DeleteSymbolFromLibrary()
bool IsCurrentSymbol(const LIB_ID &aLibId) const
Restore the empty editor screen, without any symbol or library selected.
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
LIB_ID GetTargetLibId() const
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
void FocusOnLibId(const LIB_ID &aLibID)
void Save()
Save the selected symbol or library.
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
int GetTreeSelectionCount() const
void SetConvert(int aConvert)
void SaveSymbolCopyAs()
Save the currently selected symbol to a new name and/or location.
void DuplicateSymbol(bool aFromClipboard)
Insert a duplicate symbol.
std::vector< LIB_ID > GetSelectedLibIds() const
LIB_TREE_NODE * GetCurrentTreeNode() const
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void UpdateMsgPanel() override
Redraw the message panel.
void CreateNewSymbol(const wxString &newName=wxEmptyString)
Create a new symbol in the selected library.
void UpdateTitle()
Update the main window title bar with the current library name and read only status of the library.
void SVGPlotSymbol(const wxString &aFullFileName, VECTOR2I aOffset)
Create the SVG print file for the current edited symbol.
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
void DdAddLibrary(wxString aLibFile)
Add a library dropped file to the symbol library table.
void UpdateLibraryTree(const wxDataViewItem &aTreeItem, LIB_SYMBOL *aSymbol)
Update a symbol node in the library tree.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void SaveLibraryAs()
Save the currently selected library to a new file.
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &oldAlias, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
void SetSymbolModified(const wxString &aAlias, const wxString &aLibrary)
bool SymbolExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
Symbol library viewer main window.
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
LIB_SYMBOL * GetSelectedSymbol() const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
Generic, UI-independent tool event.
Definition: tool_event.h:167
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
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:460
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 m_menu
The functions below are not yet implemented - their interface may change.
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:145
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:230
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
bool empty() const
Definition: utf8.h:103
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:305
This file is part of the common library.
#define _(s)
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
const std::string SVGFileExtension
wxString SVGFileWildcard()
wxString PngFileWildcard()
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
STL namespace.
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
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
constexpr int IUToMils(int iu) const
Definition: base_units.h:100
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
Definition of file extensions used in Kicad.