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-2022 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* current = editFrame->GetCurrentTreeNode();
74 return current && current->m_Type == LIB_TREE_NODE::LIB && current->m_Pinned;
75 };
76 auto unpinnedLibSelectedCondition =
77 [ editFrame ](const SELECTION& aSel )
78 {
79 LIB_TREE_NODE* current = editFrame->GetCurrentTreeNode();
80 return current && current->m_Type == LIB_TREE_NODE::LIB && !current->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::saveSymbolAs, 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::saveSymbolAs ) )
222 editFrame->SaveSymbolAs();
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
323{
325 {
326 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
327 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
328
329 LIB_ID libId = editFrame->GetTreeLIBID();
330 wxString libName = libId.GetLibNickname();
331 wxString symbolName = libId.GetLibItemName();
332 wxString newName = symbolName;
333 bool done = false;
334
335 if( !libMgr.LibraryExists( libName ) )
336 return 0;
337
338 while( !done )
339 {
340 wxTextEntryDialog dlg( m_frame, _( "New name:" ), _( "Change Symbol Name" ), newName );
341
342 if( dlg.ShowModal() != wxID_OK )
343 return 0; // canceled by user
344
345 newName = EscapeString( dlg.GetValue(), CTX_LIBID );
346 newName.Trim( true ).Trim( false );
347
348 if( newName.IsEmpty() )
349 {
350 DisplayErrorMessage( editFrame, _( "Symbol name cannot be empty." ) );
351 }
352 else if( libMgr.SymbolExists( newName, libName ) )
353 {
354 DisplayErrorMessage( editFrame, wxString::Format( _( "Symbol name '%s' already "
355 "in use in library '%s'." ),
356 UnescapeString( newName ),
357 libName ) );
358 newName = symbolName;
359 }
360 else
361 {
362 done = true;
363 }
364 }
365
366 wxString oldName = symbolName;
367 LIB_SYMBOL* libSymbol = nullptr;
368
369 if( editFrame->IsCurrentSymbol( libId ) )
370 {
371 // Update buffered copy
372 libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
373
374 libSymbol->SetName( newName );
375 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
376
377 libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
378
379 // Now update canvasy copy
380 libSymbol = editFrame->GetCurSymbol();
381
382 libSymbol->SetName( newName );
383 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
384
385 editFrame->RebuildView();
386 editFrame->OnModify();
387
388 // N.B. The view needs to be rebuilt first as the Symbol Properties change may
389 // invalidate the view pointers by rebuilting the field table
390 editFrame->UpdateMsgPanel();
391 }
392 else
393 {
394 libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
395
396 libSymbol->SetName( newName );
397 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
398
399 libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
400 libMgr.SetSymbolModified( newName, libName );
401 }
402
403 wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( libId );
404 editFrame->UpdateLibraryTree( treeItem, libSymbol );
405 editFrame->FocusOnLibId( LIB_ID( libName, newName ) );
406 }
407
408 return 0;
409}
410
411
413{
416
418 {
421
422 SYMBOL_EDIT_FRAME* symbolEditor = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
423 symbolEditor->SetConvert( convert );
424
426 symbolEditor->RebuildView();
427 }
429 {
430 SYMBOL_VIEWER_FRAME* symbolViewer = static_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
431 symbolViewer->SetUnitAndConvert( symbolViewer->GetUnit(), convert );
432 }
433
434 return 0;
435}
436
437
439{
441 {
442 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
443 LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
444
445 if( currentNode && !currentNode->m_Pinned )
446 {
447 m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), true );
448
449 currentNode->m_Pinned = true;
450 editFrame->RegenerateLibraryTree();
451 }
452 }
453
454 return 0;
455}
456
457
459{
461 {
462 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
463 LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
464
465 if( currentNode && currentNode->m_Pinned )
466 {
467 m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), true );
468
469 currentNode->m_Pinned = false;
470 editFrame->RegenerateLibraryTree();
471 }
472 }
473
474 return 0;
475}
476
477
479{
481 {
482 wxCommandEvent dummy;
483 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->OnToggleSymbolTree( dummy );
484 }
485
486 return 0;
487}
488
489
491{
493 renderSettings->m_ShowPinsElectricalType = !renderSettings->m_ShowPinsElectricalType;
494
495 // Update canvas
498
499 return 0;
500}
501
502
504{
506 renderSettings->m_ShowPinNumbers = !renderSettings->m_ShowPinNumbers;
507
508 // Update canvas
511
512 return 0;
513}
514
515
517{
518 if( !m_isSymbolEditor )
519 return 0;
520
521 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
522 editFrame->m_SyncPinEdit = !editFrame->m_SyncPinEdit;
523
524 return 0;
525}
526
527
529{
530 if( !m_isSymbolEditor )
531 return 0;
532
533 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
534 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
535
536 if( !symbol )
537 {
538 wxMessageBox( _( "No symbol to export" ) );
539 return 0;
540 }
541
542 wxFileName fn( symbol->GetName() );
543 fn.SetExt( "png" );
544
545 wxString projectPath = wxPathOnly( m_frame->Prj().GetProjectFullName() );
546
547 wxFileDialog dlg( editFrame, _( "Image File Name" ), projectPath, fn.GetFullName(),
548 PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
549
550 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
551 {
552 // calling wxYield is mandatory under Linux, after closing the file selector dialog
553 // to refresh the screen before creating the PNG or JPEG image from screen
554 wxYield();
555
556 if( !SaveCanvasImageToFile( editFrame, dlg.GetPath(), BITMAP_TYPE::PNG ) )
557 {
558 wxMessageBox( wxString::Format( _( "Can't save file '%s'." ), dlg.GetPath() ) );
559 }
560 }
561
562 return 0;
563}
564
565
567{
568 if( !m_isSymbolEditor )
569 return 0;
570
571 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
572 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
573
574 if( !symbol )
575 {
576 wxMessageBox( _( "No symbol to export" ) );
577 return 0;
578 }
579
580 wxFileName fn( symbol->GetName() );
581 fn.SetExt( SVGFileExtension );
582
583 wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
584
585 wxString fullFileName = wxFileSelector( _( "SVG File Name" ), pro_dir, fn.GetFullName(),
586 SVGFileExtension, SVGFileWildcard(), wxFD_SAVE,
587 m_frame );
588
589 if( !fullFileName.IsEmpty() )
590 {
591 PAGE_INFO pageSave = editFrame->GetScreen()->GetPageSettings();
592 PAGE_INFO pageTemp = pageSave;
593
594 BOX2I symbolBBox = symbol->GetUnitBoundingBox( editFrame->GetUnit(),
595 editFrame->GetConvert(), false );
596
597 // Add a small margin (10% of size)to the plot bounding box
598 symbolBBox.Inflate( symbolBBox.GetSize().x * 0.1, symbolBBox.GetSize().y * 0.1 );
599
600 pageTemp.SetWidthMils( schIUScale.IUToMils( symbolBBox.GetSize().x ) );
601 pageTemp.SetHeightMils( schIUScale.IUToMils( symbolBBox.GetSize().y ) );
602
603 // Add an offet to plot the symbol centered on the page.
604 VECTOR2I plot_offset = symbolBBox.GetOrigin();
605
606 editFrame->GetScreen()->SetPageSettings( pageTemp );
607 editFrame->SVGPlotSymbol( fullFileName, -plot_offset );
608 editFrame->GetScreen()->SetPageSettings( pageSave );
609 }
610
611 return 0;
612}
613
614
616{
617 LIB_SYMBOL* libSymbol = nullptr;
618 LIB_ID libId;
619 int unit, convert;
620
621 if( m_isSymbolEditor )
622 {
623 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
624
625 libSymbol = editFrame->GetCurSymbol();
626 unit = editFrame->GetUnit();
627 convert = editFrame->GetConvert();
628
629 if( libSymbol )
630 libId = libSymbol->GetLibId();
631 }
632 else
633 {
634 SYMBOL_VIEWER_FRAME* viewerFrame = getEditFrame<SYMBOL_VIEWER_FRAME>();
635
636 if( viewerFrame->IsModal() )
637 {
638 // if we're modal then we just need to return the symbol selection; the caller is
639 // already in a EE_ACTIONS::placeSymbol coroutine.
640 viewerFrame->FinishModal();
641 return 0;
642 }
643 else
644 {
645 libSymbol = viewerFrame->GetSelectedSymbol();
646 unit = viewerFrame->GetUnit();
647 convert = viewerFrame->GetConvert();
648
649 if( libSymbol )
650 libId = libSymbol->GetLibId();
651 }
652 }
653
654 if( libSymbol )
655 {
656 SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH, false );
657
658 if( !schframe ) // happens when the schematic editor is not active (or closed)
659 {
660 DisplayErrorMessage( m_frame, _( "No schematic currently open." ) );
661 return 0;
662 }
663
664 wxWindow* blocking_dialog = schframe->Kiway().GetBlockingDialog();
665
666 if( blocking_dialog )
667 {
668 blocking_dialog->Raise();
669 wxBell();
670 return 0;
671 }
672
673 wxCHECK( libSymbol->GetLibId().IsValid(), 0 );
674
675 SCH_SYMBOL* symbol = new SCH_SYMBOL( *libSymbol, libId, &schframe->GetCurrentSheet(),
676 unit, convert );
677
678 symbol->SetParent( schframe->GetScreen() );
679
680 if( schframe->eeconfig()->m_AutoplaceFields.enable )
681 symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
682
683 schframe->Raise();
684 schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, false, symbol );
685 }
686
687 return 0;
688}
689
690
692{
699
701
707
718
721
729}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:216
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:113
static TOOL_ACTION saveAll
Definition: actions.h:54
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION unpinLibrary
Definition: actions.h:114
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
const Vec & GetOrigin() const
Definition: box2.h:183
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
const Vec & GetSize() const
Definition: box2.h:179
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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:175
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION deleteSymbol
Definition: ee_actions.h:204
static TOOL_ACTION cutSymbol
Definition: ee_actions.h:205
static TOOL_ACTION saveSymbolAs
Definition: ee_actions.h:198
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:202
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:136
static TOOL_ACTION newSymbol
Definition: ee_actions.h:199
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:135
static TOOL_ACTION editSymbol
Definition: ee_actions.h:201
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:197
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:178
static TOOL_ACTION showPinNumbers
Definition: ee_actions.h:245
static TOOL_ACTION exportSymbolAsSVG
Definition: ee_actions.h:250
static TOOL_ACTION importSymbol
Definition: ee_actions.h:208
static TOOL_ACTION hideSymbolTree
Definition: ee_actions.h:247
static TOOL_ACTION copySymbol
Definition: ee_actions.h:206
static TOOL_ACTION renameSymbol
Definition: ee_actions.h:203
static TOOL_ACTION exportSymbol
Definition: ee_actions.h:209
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:238
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:246
static TOOL_ACTION exportSymbolView
Definition: ee_actions.h:249
static TOOL_ACTION deriveFromExistingSymbol
Definition: ee_actions.h:200
static TOOL_ACTION pasteSymbol
Definition: ee_actions.h:207
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:244
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:202
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:1501
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
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
Definition: kiway_player.h:159
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:685
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:70
@ DEMORGAN
Definition: lib_item.h:70
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:146
wxString GetName() const override
Definition: lib_symbol.h:143
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:572
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:54
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:245
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:259
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:120
void UnpinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:177
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:156
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 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.
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 RenameSymbol(const TOOL_EVENT &aEvent)
int CutCopyDelete(const TOOL_EVENT &aEvent)
The symbol library editor main window.
void CreateNewSymbol(const wxString &inheritFromSymbolName=wxEmptyString)
Create a new symbol in the selected library.
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)
void SaveSymbolAs()
Save the currently selected symbol to a new name and/or location.
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 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 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.
void FinishModal()
Send the selected symbol back to the caller.
LIB_SYMBOL * GetSelectedSymbol() const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
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:156
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
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 m_menu
The functions below are not yet implemented - their interface may change.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
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:308
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
@ FRAME_SCH_VIEWER_MODAL
Definition: frame_type.h:37
const std::string SVGFileExtension
wxString SVGFileWildcard()
wxString PngFileWildcard()
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:55
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.