KiCad PCB EDA Suite
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->GetTreeLIBID();
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
106 ctxMenu.AddSeparator();
107 ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition || libInferredCondition );
108 ctxMenu.AddItem( EE_ACTIONS::saveLibraryAs, libSelectedCondition );
109 ctxMenu.AddItem( EE_ACTIONS::saveSymbolAs, saveSymbolAsCondition );
110 ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition || libInferredCondition );
111
112 ctxMenu.AddSeparator();
113 ctxMenu.AddItem( EE_ACTIONS::cutSymbol, symbolSelectedCondition || multiSelectedCondition );
114 ctxMenu.AddItem( EE_ACTIONS::copySymbol, symbolSelectedCondition || multiSelectedCondition );
115 ctxMenu.AddItem( EE_ACTIONS::pasteSymbol, libInferredCondition );
116 ctxMenu.AddItem( EE_ACTIONS::duplicateSymbol, symbolSelectedCondition );
117 ctxMenu.AddItem( EE_ACTIONS::renameSymbol, symbolSelectedCondition );
118 ctxMenu.AddItem( EE_ACTIONS::deleteSymbol, symbolSelectedCondition || multiSelectedCondition );
119
120 ctxMenu.AddSeparator();
121 ctxMenu.AddItem( EE_ACTIONS::importSymbol, libInferredCondition );
122 ctxMenu.AddItem( EE_ACTIONS::exportSymbol, symbolSelectedCondition );
123
124 // If we've got nothing else to show, at least show a hide tree option
125 ctxMenu.AddItem( EE_ACTIONS::hideSymbolTree, !libInferredCondition );
126 }
127
128 return true;
129}
130
131
133{
134 bool createNew = aEvent.IsAction( &ACTIONS::newLibrary );
135
137 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->AddLibraryFile( createNew );
138
139 return 0;
140}
141
142
144{
145 wxString libFile = *aEvent.Parameter<wxString*>();
147 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->DdAddLibrary( libFile );
148
149 return 0;
150}
151
152
154{
156 {
157 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
158 int unit = 0;
159 LIB_ID partId = editFrame->GetTreeLIBID( &unit );
160
161 editFrame->LoadSymbol( partId.GetLibItemName(), partId.GetLibNickname(), unit );
162 }
163
164 return 0;
165}
166
167
169{
171 {
172 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
173
174 LIB_ID sel = editFrame->GetTreeLIBID();
175 const wxString& libName = sel.GetLibNickname();
176 wxString msg;
177
178 if( libName.IsEmpty() )
179 {
180 msg.Printf( _( "No symbol library selected." ) );
182 return 0;
183 }
184
185 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
186 {
187 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
189 return 0;
190 }
191
192 if( aEvent.IsAction( &EE_ACTIONS::newSymbol ) )
193 editFrame->CreateNewSymbol();
194 else if( aEvent.IsAction( &EE_ACTIONS::importSymbol ) )
195 editFrame->ImportSymbol();
196 }
197
198 return 0;
199}
200
201
203{
205 {
206 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
207
208 if( aEvt.IsAction( &EE_ACTIONS::save ) )
209 editFrame->Save();
210 else if( aEvt.IsAction( &EE_ACTIONS::saveLibraryAs ) )
211 editFrame->SaveLibraryAs();
212 else if( aEvt.IsAction( &EE_ACTIONS::saveSymbolAs ) )
213 editFrame->SaveSymbolAs();
214 else if( aEvt.IsAction( &EE_ACTIONS::saveAll ) )
215 editFrame->SaveAll();
216 }
217
218 return 0;
219}
220
221
223{
225 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->Revert();
226
227 return 0;
228}
229
230
232{
234 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->ExportSymbol();
235
236 return 0;
237}
238
239
241{
243 {
244 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
245
247 editFrame->CopySymbolToClipboard();
248
250 {
251 bool hasWritableLibs = false;
252 wxString msg;
253
254 for( LIB_ID& sel : editFrame->GetSelectedLibIds() )
255 {
256 const wxString& libName = sel.GetLibNickname();
257
258 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
259 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
260 else
261 hasWritableLibs = true;
262 }
263
264 if( !msg.IsEmpty() )
266
267 if( !hasWritableLibs )
268 return 0;
269
270 editFrame->DeleteSymbolFromLibrary();
271 }
272 }
273
274 return 0;
275}
276
277
279{
281 {
282 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
283 LIB_ID sel = editFrame->GetTargetLibId();
284 // DuplicateSymbol() is called to duplicate a symbol, or to paste a previously
285 // saved symbol in clipboard
286 bool isPasteAction = aEvent.IsAction( &EE_ACTIONS::pasteSymbol );
287 wxString msg;
288
289 if( !sel.IsValid() && !isPasteAction )
290 {
291 // When duplicating a symbol, a source symbol must exists.
292 msg.Printf( _( "No symbol selected" ) );
294 return 0;
295 }
296
297 const wxString& libName = sel.GetLibNickname();
298
299 if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
300 {
301 msg.Printf( _( "Symbol library '%s' is not writable." ), libName );
303 return 0;
304 }
305
306 editFrame->DuplicateSymbol( isPasteAction );
307 }
308
309 return 0;
310}
311
312
314{
316 {
317 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
318 LIB_SYMBOL_LIBRARY_MANAGER& libMgr = editFrame->GetLibManager();
319
320 LIB_ID libId = editFrame->GetTreeLIBID();
321 wxString libName = libId.GetLibNickname();
322 wxString symbolName = libId.GetLibItemName();
323 wxString newName = symbolName;
324 bool done = false;
325
326 if( !libMgr.LibraryExists( libName ) )
327 return 0;
328
329 while( !done )
330 {
331 wxTextEntryDialog dlg( m_frame, _( "New name:" ), _( "Change Symbol Name" ), newName );
332
333 if( dlg.ShowModal() != wxID_OK )
334 return 0; // canceled by user
335
336 newName = EscapeString( dlg.GetValue(), CTX_LIBID );
337 newName.Trim( true ).Trim( false );
338
339 if( newName.IsEmpty() )
340 {
341 DisplayErrorMessage( editFrame, _( "Symbol name cannot be empty." ) );
342 }
343 else if( libMgr.SymbolExists( newName, libName ) )
344 {
345 DisplayErrorMessage( editFrame, wxString::Format( _( "Symbol name '%s' already "
346 "in use in library '%s'." ),
347 UnescapeString( newName ),
348 libName ) );
349 newName = symbolName;
350 }
351 else
352 {
353 done = true;
354 }
355 }
356
357 wxString oldName = symbolName;
358 LIB_SYMBOL* libSymbol = nullptr;
359
360 if( editFrame->IsCurrentSymbol( libId ) )
361 {
362 // Update buffered copy
363 libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
364
365 libSymbol->SetName( newName );
366 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
367
368 libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
369
370 // Now update canvasy copy
371 libSymbol = editFrame->GetCurSymbol();
372
373 libSymbol->SetName( newName );
374 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
375
376 editFrame->RebuildView();
377 editFrame->OnModify();
378
379 // N.B. The view needs to be rebuilt first as the Symbol Properties change may
380 // invalidate the view pointers by rebuilting the field table
381 editFrame->UpdateMsgPanel();
382 }
383 else
384 {
385 libSymbol = libMgr.GetBufferedSymbol( oldName, libName );
386
387 libSymbol->SetName( newName );
388 libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
389
390 libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
391 libMgr.SetSymbolModified( newName, libName );
392 }
393
394 wxDataViewItem treeItem = libMgr.GetAdapter()->FindItem( libId );
395 editFrame->UpdateLibraryTree( treeItem, libSymbol );
396 editFrame->FocusOnLibId( LIB_ID( libName, newName ) );
397 }
398
399 return 0;
400}
401
402
404{
406 LIB_ITEM::LIB_CONVERT::BASE : LIB_ITEM::LIB_CONVERT::DEMORGAN;
407
409 {
412
413 SYMBOL_EDIT_FRAME* symbolEditor = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
414 symbolEditor->SetConvert( convert );
415
417 symbolEditor->RebuildView();
418 }
420 {
421 SYMBOL_VIEWER_FRAME* symbolViewer = static_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
422 symbolViewer->SetUnitAndConvert( symbolViewer->GetUnit(), convert );
423 }
424
425 return 0;
426}
427
428
430{
432 {
433 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
434 LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
435
436 if( currentNode && !currentNode->m_Pinned )
437 {
438 m_frame->Prj().PinLibrary( currentNode->m_LibId.GetLibNickname(), true );
439
440 currentNode->m_Pinned = true;
441 editFrame->RegenerateLibraryTree();
442 }
443 }
444
445 return 0;
446}
447
448
450{
452 {
453 SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
454 LIB_TREE_NODE* currentNode = editFrame->GetCurrentTreeNode();
455
456 if( currentNode && currentNode->m_Pinned )
457 {
458 m_frame->Prj().UnpinLibrary( currentNode->m_LibId.GetLibNickname(), true );
459
460 currentNode->m_Pinned = false;
461 editFrame->RegenerateLibraryTree();
462 }
463 }
464
465 return 0;
466}
467
468
470{
472 {
473 wxCommandEvent dummy;
474 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->OnToggleSymbolTree( dummy );
475 }
476
477 return 0;
478}
479
480
482{
484 renderSettings->m_ShowPinsElectricalType = !renderSettings->m_ShowPinsElectricalType;
485
486 // Update canvas
489
490 return 0;
491}
492
493
495{
497 renderSettings->m_ShowPinNumbers = !renderSettings->m_ShowPinNumbers;
498
499 // Update canvas
502
503 return 0;
504}
505
506
508{
509 if( !m_isSymbolEditor )
510 return 0;
511
512 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
513 editFrame->m_SyncPinEdit = !editFrame->m_SyncPinEdit;
514
515 return 0;
516}
517
518
520{
521 if( !m_isSymbolEditor )
522 return 0;
523
524 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
525 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
526
527 if( !symbol )
528 {
529 wxMessageBox( _( "No symbol to export" ) );
530 return 0;
531 }
532
533 wxFileName fn( symbol->GetName() );
534 fn.SetExt( "png" );
535
536 wxString projectPath = wxPathOnly( m_frame->Prj().GetProjectFullName() );
537
538 wxFileDialog dlg( editFrame, _( "Image File Name" ), projectPath, fn.GetFullName(),
539 PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
540
541 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
542 {
543 // calling wxYield is mandatory under Linux, after closing the file selector dialog
544 // to refresh the screen before creating the PNG or JPEG image from screen
545 wxYield();
546
547 if( !SaveCanvasImageToFile( editFrame, dlg.GetPath(), BITMAP_TYPE::PNG ) )
548 {
549 wxMessageBox( wxString::Format( _( "Can't save file '%s'." ), dlg.GetPath() ) );
550 }
551 }
552
553 return 0;
554}
555
556
558{
559 if( !m_isSymbolEditor )
560 return 0;
561
562 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
563 LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
564
565 if( !symbol )
566 {
567 wxMessageBox( _( "No symbol to export" ) );
568 return 0;
569 }
570
571 wxFileName fn( symbol->GetName() );
572 fn.SetExt( SVGFileExtension );
573
574 wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
575
576 wxString fullFileName = wxFileSelector( _( "SVG File Name" ), pro_dir, fn.GetFullName(),
577 SVGFileExtension, SVGFileWildcard(), wxFD_SAVE,
578 m_frame );
579
580 if( !fullFileName.IsEmpty() )
581 {
582 PAGE_INFO pageSave = editFrame->GetScreen()->GetPageSettings();
583 PAGE_INFO pageTemp = pageSave;
584
585 VECTOR2I symbolSize = symbol->GetUnitBoundingBox( editFrame->GetUnit(),
586 editFrame->GetConvert() ).GetSize();
587
588 // Add a small margin to the plot bounding box
589 pageTemp.SetWidthMils( int( symbolSize.x * 1.2 ) );
590 pageTemp.SetHeightMils( int( symbolSize.y * 1.2 ) );
591
592 editFrame->GetScreen()->SetPageSettings( pageTemp );
593 editFrame->SVGPlotSymbol( fullFileName );
594 editFrame->GetScreen()->SetPageSettings( pageSave );
595 }
596
597 return 0;
598}
599
600
602{
603 LIB_SYMBOL* libSymbol = nullptr;
604 LIB_ID libId;
605 int unit, convert;
606
607 if( m_isSymbolEditor )
608 {
609 SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
610
611 libSymbol = editFrame->GetCurSymbol();
612 unit = editFrame->GetUnit();
613 convert = editFrame->GetConvert();
614
615 if( libSymbol )
616 libId = libSymbol->GetLibId();
617 }
618 else
619 {
620 SYMBOL_VIEWER_FRAME* viewerFrame = getEditFrame<SYMBOL_VIEWER_FRAME>();
621
622 if( viewerFrame->IsModal() )
623 {
624 // if we're modal then we just need to return the symbol selection; the caller is
625 // already in a EE_ACTIONS::placeSymbol coroutine.
626 viewerFrame->FinishModal();
627 return 0;
628 }
629 else
630 {
631 libSymbol = viewerFrame->GetSelectedSymbol();
632 unit = viewerFrame->GetUnit();
633 convert = viewerFrame->GetConvert();
634
635 if( libSymbol )
636 libId = libSymbol->GetLibId();
637 }
638 }
639
640 if( libSymbol )
641 {
642 SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH, false );
643
644 if( !schframe ) // happens when the schematic editor is not active (or closed)
645 {
646 DisplayErrorMessage( m_frame, _( "No schematic currently open." ) );
647 return 0;
648 }
649
650 wxWindow* blocking_dialog = schframe->Kiway().GetBlockingDialog();
651
652 if( blocking_dialog )
653 blocking_dialog->Close( true );
654
655 wxCHECK( libSymbol->GetLibId().IsValid(), 0 );
656
657 SCH_SYMBOL* symbol = new SCH_SYMBOL( *libSymbol, libId, &schframe->GetCurrentSheet(),
658 unit, convert );
659
660 symbol->SetParent( schframe->GetScreen() );
661
662 if( schframe->eeconfig()->m_AutoplaceFields.enable )
663 symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
664
665 schframe->Raise();
666 schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, false, symbol );
667 }
668
669 return 0;
670}
671
672
674{
680
682
688
699
702
710}
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:207
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:112
static TOOL_ACTION saveAll
Definition: actions.h:54
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION unpinLibrary
Definition: actions.h:113
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
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 UpdateMsgPanel()
Redraw the message panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION deleteSymbol
Definition: ee_actions.h:190
static TOOL_ACTION cutSymbol
Definition: ee_actions.h:191
static TOOL_ACTION saveSymbolAs
Definition: ee_actions.h:185
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:81
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION duplicateSymbol
Definition: ee_actions.h:188
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:138
static TOOL_ACTION newSymbol
Definition: ee_actions.h:186
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:137
static TOOL_ACTION editSymbol
Definition: ee_actions.h:187
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:184
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:179
static TOOL_ACTION showPinNumbers
Definition: ee_actions.h:228
static TOOL_ACTION exportSymbolAsSVG
Definition: ee_actions.h:233
static TOOL_ACTION importSymbol
Definition: ee_actions.h:194
static TOOL_ACTION hideSymbolTree
Definition: ee_actions.h:230
static TOOL_ACTION copySymbol
Definition: ee_actions.h:192
static TOOL_ACTION renameSymbol
Definition: ee_actions.h:189
static TOOL_ACTION exportSymbol
Definition: ee_actions.h:195
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:221
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:229
static TOOL_ACTION exportSymbolView
Definition: ee_actions.h:232
static TOOL_ACTION pasteSymbol
Definition: ee_actions.h:193
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:227
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:184
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:1478
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:173
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:617
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:165
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
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:98
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
LIB_ID GetLibId() const override
Definition: lib_symbol.h:139
wxString GetName() const override
Definition: lib_symbol.h:136
const BOX2I GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
Definition: lib_symbol.cpp:962
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:441
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:244
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:258
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:119
void UnpinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:176
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:155
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:130
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:131
Schematic symbol object.
Definition: sch_symbol.h:79
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 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.
void SVGPlotSymbol(const wxString &aFullFileName)
Create the SVG print file for the current edited symbol.
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 CreateNewSymbol()
Create a new symbol in the selected library.
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:214
@ MODEL_RELOAD
Model changes (required full reload)
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:88
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:299
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
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
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
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
Definition of file extensions used in Kicad.