KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_base_frame.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) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The 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 <advanced_config.h>
26#include <base_units.h>
27#include <kiway.h>
29#include <pgm_base.h>
30#include <eda_list_dialog.h>
31#include <eeschema_settings.h>
35#include <sch_draw_panel.h>
36#include <sch_group.h>
37#include <sch_view.h>
38#include <sch_painter.h>
39#include <sch_shape.h>
41#include <confirm.h>
43#include <project_sch.h>
44#include <symbol_library.h>
45#include <symbol_lib_table.h>
46#include <sch_base_frame.h>
47#include <design_block.h>
49#include <tool/action_toolbar.h>
50#include <tool/tool_manager.h>
53#include <view/view_controls.h>
54#include <wx/choicdlg.h>
55#include <wx/fswatcher.h>
56#include <wx/log.h>
57#include <wx/msgdlg.h>
58
60
61
63 SYMBOL_LIB* aCacheLib, wxWindow* aParent, bool aShowErrorMsg )
64{
65 wxCHECK_MSG( aLibTable, nullptr, wxS( "Invalid symbol library table." ) );
66
67 LIB_SYMBOL* symbol = nullptr;
68
69 try
70 {
71 symbol = aLibTable->LoadSymbol( aLibId );
72
73 if( !symbol && aCacheLib )
74 {
75 wxCHECK_MSG( aCacheLib->IsCache(), nullptr, wxS( "Invalid cache library." ) );
76
77 wxString cacheName = aLibId.GetLibNickname().wx_str();
78 cacheName << "_" << aLibId.GetLibItemName();
79 symbol = aCacheLib->FindSymbol( cacheName );
80 }
81 }
82 catch( const IO_ERROR& ioe )
83 {
84 if( aShowErrorMsg )
85 {
86 wxString msg = wxString::Format( _( "Error loading symbol %s from library '%s'." ),
87 aLibId.GetLibItemName().wx_str(),
88 aLibId.GetLibNickname().wx_str() );
89 DisplayErrorMessage( aParent, msg, ioe.What() );
90 }
91 }
92
93 return symbol;
94}
95
96
97SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindowType,
98 const wxString& aTitle, const wxPoint& aPosition,
99 const wxSize& aSize, long aStyle, const wxString& aFrameName ) :
100 EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle,
101 aFrameName, schIUScale ),
102 m_base_frame_defaults( nullptr, "base_Frame_defaults" ),
103 m_selectionFilterPanel( nullptr ),
104 m_inSymChangeTimerEvent( false )
105{
106 if( ( aStyle & wxFRAME_NO_TASKBAR ) == 0 )
107 createCanvas();
108
109 Bind( wxEVT_IDLE,
110 [this]( wxIdleEvent& aEvent )
111 {
112 // Handle cursor adjustments. While we can get motion and key events through
113 // wxWidgets, we can't get modifier-key-up events.
114 if( m_toolManager )
115 {
117
118 if( selTool )
119 selTool->OnIdle( aEvent );
120 }
121 } );
122
124}
125
126
129{}
130
131
133{
135}
136
137
139{
140 return dynamic_cast<EESCHEMA_SETTINGS*>( config() );
141}
142
143
145{
146 return dynamic_cast<SYMBOL_EDITOR_SETTINGS*>( config() );
147}
148
149
151{
152 switch( GetFrameType() )
153 {
154 case FRAME_SCH:
155 default:
156 return GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
157
159 case FRAME_SCH_VIEWER:
161 return GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
162 }
163}
164
165
166void SCH_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
167{
168 GetScreen()->SetPageSettings( aPageSettings );
169}
170
171
173{
174 return GetScreen()->GetPageSettings();
175}
176
177
179{
180 // GetSizeIU is compile time dependent:
182}
183
184
186{
187 wxASSERT( GetScreen() );
188 return GetScreen()->GetTitleBlock();
189}
190
191
193{
194 wxASSERT( GetScreen() );
195 GetScreen()->SetTitleBlock( aTitleBlock );
196}
197
198
200{
201 wxString line;
202 BASE_SCREEN* screen = GetScreen();
203
204 if( !screen )
205 return;
206
208
209 // Display absolute and relative coordinates
211 VECTOR2D d = cursorPos - screen->m_LocalOrigin;
212
213 line.Printf( wxS( "X %s Y %s" ),
214 MessageTextFromValue( cursorPos.x, false ),
215 MessageTextFromValue( cursorPos.y, false ) );
216 SetStatusText( line, 2 );
217
218 line.Printf( wxS( "dx %s dy %s dist %s" ),
219 MessageTextFromValue( d.x, false ),
220 MessageTextFromValue( d.y, false ),
221 MessageTextFromValue( hypot( d.x, d.y ), false ) );
222 SetStatusText( line, 3 );
223
226}
227
228
229LIB_SYMBOL* SCH_BASE_FRAME::GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib,
230 bool aShowErrorMsg )
231{
232 SYMBOL_LIB* cache =
233 ( aUseCacheLib ) ? PROJECT_SCH::SchLibs( &Prj() )->GetCacheLibrary() : nullptr;
234
235 return SchGetLibSymbol( aLibId, PROJECT_SCH::SchSymbolLibTable( &Prj() ), cache, this,
236 aShowErrorMsg );
237}
238
239
240bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
241{
242 wxString msg;
243 bool success = true;
244
245 if( aGlobal )
246 {
247 try
248 {
250 }
251 catch( const IO_ERROR& ioe )
252 {
253 success = false;
254 msg.Printf( _( "Error saving global symbol library table:\n%s" ), ioe.What() );
255 DisplayErrorMessage( this, msg );
256 }
257 }
258
259 if( aProject && !Prj().GetProjectName().IsEmpty() )
260 {
261 wxFileName fn( Prj().GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
262
263 try
264 {
265 PROJECT_SCH::SchSymbolLibTable( &Prj() )->Save( fn.GetFullPath() );
266 }
267 catch( const IO_ERROR& ioe )
268 {
269 success = false;
270 msg.Printf( _( "Error saving project-specific symbol library table:\n%s" ),
271 ioe.What() );
272 DisplayErrorMessage( this, msg );
273 }
274 }
275
276 return success;
277}
278
279
281{
282 // If no project is loaded, always work with the global table
283 if( Prj().IsNullProject() )
284 {
286
287 if( aOptional )
288 {
289 wxMessageDialog dlg( this, _( "Add the library to the global library table?" ),
290 _( "Add To Global Library Table" ), wxYES_NO );
291
292 if( dlg.ShowModal() != wxID_OK )
293 ret = nullptr;
294 }
295
296 return ret;
297 }
298
299 wxArrayString libTableNames;
300 libTableNames.Add( _( "Global" ) );
301 libTableNames.Add( _( "Project" ) );
302
303 wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
304 _( "Add To Library Table" ), libTableNames );
305
306 if( aOptional )
307 {
308 dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
309 dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
310 }
311
312 if( dlg.ShowModal() != wxID_OK )
313 return nullptr;
314
315 switch( dlg.GetSelection() )
316 {
317 case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
318 case 1: return PROJECT_SCH::SchSymbolLibTable( &Prj() );
319 default: return nullptr;
320 }
321}
322
323
324void SCH_BASE_FRAME::RedrawScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer )
325{
326 GetCanvas()->GetView()->SetCenter( aCenterPoint );
327
328 if( aWarpPointer )
330
331 GetCanvas()->Refresh();
332}
333
334
336{
337 if( GetCanvas() && GetCanvas()->GetView() )
338 {
341 }
342}
343
344
346{
347 return static_cast<SCH_DRAW_PANEL*>( EDA_DRAW_FRAME::GetCanvas() );
348}
349
350
352{
353 if( GetCanvas() && GetCanvas()->GetView() )
354 {
355 if( KIGFX::PAINTER* painter = GetCanvas()->GetView()->GetPainter() )
356 return static_cast<SCH_RENDER_SETTINGS*>( painter->GetSettings() );
357 }
358
359 return nullptr;
360}
361
362
364{
366
367 SetCanvas( new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_frameSize,
370}
371
372
374{
376
377 try
378 {
379 if( !m_spaceMouse )
380 m_spaceMouse = std::make_unique<NL_SCHEMATIC_PLUGIN>();
381
382 m_spaceMouse->SetCanvas( GetCanvas() );
383 }
384 catch( const std::system_error& e )
385 {
386 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
387 }
388}
389
390
391void SCH_BASE_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
392{
393 EDA_ITEM* parent = aItem->GetParent();
394
395 if( aItem->Type() == SCH_SHEET_PIN_T )
396 {
397 // Sheet pins aren't in the view. Refresh their parent.
398 if( parent )
399 GetCanvas()->GetView()->Update( parent );
400 }
401 else
402 {
403 if( aItem->Type() == SCH_SHAPE_T )
404 static_cast<SCH_SHAPE*>( aItem )->UpdateHatching();
405
406 if( !isAddOrDelete )
407 GetCanvas()->GetView()->Update( aItem );
408
409 // Some children are drawn from their parents. Mark them for re-paint.
410 if( parent && ( parent->Type() == SCH_SYMBOL_T
411 || parent->Type() == SCH_SHEET_T
412 || parent->Type() == SCH_LABEL_LOCATE_ANY_T
413 || parent->Type() == SCH_TABLE_T ) )
414 {
415 GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT );
416 }
417 }
418
419 /*
420 * Be careful when calling this. Update will invalidate RTree iterators, so you cannot
421 * call this while doing things like `for( SCH_ITEM* item : screen->Items() )`
422 */
423 if( aUpdateRtree && dynamic_cast<SCH_ITEM*>( aItem ) )
424 {
425 GetScreen()->Update( static_cast<SCH_ITEM*>( aItem ) );
426
427 /*
428 * If we are updating the group, we also need to update all the children otherwise
429 * their positions will remain stale in the RTree
430 */
431 if( SCH_GROUP* group = dynamic_cast<SCH_GROUP*>( aItem ) )
432 {
433 group->RunOnChildren(
434 [&]( SCH_ITEM* item )
435 {
436 GetScreen()->Update( item );
437 },
438 RECURSE_MODE::RECURSE );
439 }
440 }
441
442 // Calling Refresh() here introduces a bi-stable state: when doing operations on a
443 // large number of items if at some point the refresh timer times out and does a
444 // refresh it will take long enough that the next item will also time out, and the
445 // next, and the next, etc.
446 // GetCanvas()->Refresh();
447}
448
449
451{
452 // We currently have two zoom-dependent renderings: text, which is rendered as bitmap text
453 // when too small to see the difference, and selection shadows.
454 //
455 // Because non-selected text is cached by OpenGL, we only apply the bitmap performance hack
456 // to selected text items.
457 //
458 // Thus, as it currently stands, all zoom-dependent items can be found in the list of selected
459 // items.
460 if( m_toolManager )
461 {
463 SELECTION& selection = selectionTool->GetSelection();
464 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
465
466 for( EDA_ITEM* item : selection )
467 {
468 if( item->RenderAsBitmap( view->GetGAL()->GetWorldScale() ) != item->IsShownAsBitmap()
470 {
471 view->Update( item, KIGFX::REPAINT );
472
473 EDA_ITEM* parent = item->GetParent();
474
475 // Symbol children are drawn from their parents. Mark them for re-paint.
476 if( parent && parent->Type() == SCH_SYMBOL_T )
477 GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT );
478 }
479 }
480 }
481}
482
483
485{
486 // Null pointers will cause boost::ptr_vector to raise a boost::bad_pointer exception which
487 // will be unhandled. There is no valid reason to pass an invalid EDA_ITEM pointer to the
488 // screen append function.
489 wxCHECK( aItem, /* void */ );
490
491 SCH_SCREEN* screen = aScreen;
492
493 if( aScreen == nullptr )
494 screen = GetScreen();
495
496 if( aItem->Type() != SCH_TABLECELL_T )
497 screen->Append( (SCH_ITEM*) aItem );
498
499 if( screen == GetScreen() )
500 {
501 GetCanvas()->GetView()->Add( aItem );
502 UpdateItem( aItem, true ); // handle any additional parent semantics
503 }
504}
505
506
508{
509 auto screen = aScreen;
510
511 if( aScreen == nullptr )
512 screen = GetScreen();
513
514 if( screen == GetScreen() )
515 GetCanvas()->GetView()->Remove( aItem );
516
517 if( aItem->Type() != SCH_TABLECELL_T )
518 screen->Remove( (SCH_ITEM*) aItem );
519
520 if( screen == GetScreen() )
521 UpdateItem( aItem, true ); // handle any additional parent semantics
522}
523
524
526{
527 // Let tools add things to the view if necessary
528 if( m_toolManager )
530
532}
533
534
536{
537 return GetColorSettings()->GetColor( aLayer );
538}
539
540
542{
544
545 COLOR_SETTINGS* colorSettings = GetColorSettings( true );
546
547 GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( colorSettings );
549
553}
554
555
557{
558 if( !m_colorSettings || aForceRefresh )
559 {
560 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
561 wxString colorTheme = cfg ? cfg->m_ColorTheme : wxString( "" );
562
564 {
565 if( SYMBOL_EDITOR_SETTINGS* sym_edit_cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) )
566 {
567 if( !sym_edit_cfg->m_UseEeschemaColorSettings )
568 colorTheme = sym_edit_cfg->m_ColorTheme;
569 }
570 }
571
572 const_cast<SCH_BASE_FRAME*>( this )->m_colorSettings = ::GetColorSettings( colorTheme );
573 }
574
575 return m_colorSettings;
576}
577
578
580{
582}
583
584
585void SCH_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
586{
588
589 if( m_spaceMouse )
590 m_spaceMouse->SetFocus( aEvent.GetActive() );
591}
592
593
594void SCH_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
595{
597
598 if( m_spaceMouse )
599 m_spaceMouse->SetFocus( false );
600}
601
602
604{
606 PROJECT& prj = Prj();
607
608 if( PROJECT_SCH::SchSymbolLibTable( &prj )->IsEmpty() )
609 {
610 ShowInfoBarError( _( "No symbol libraries are loaded." ) );
611 return wxEmptyString;
612 }
613
614 wxArrayString headers;
615
616 headers.Add( _( "Library" ) );
617
618 std::vector< wxArrayString > itemsToDisplay;
619 std::vector< wxString > libNicknames = PROJECT_SCH::SchSymbolLibTable( &prj )->GetLogicalLibs();
620
621 for( const wxString& name : libNicknames )
622 {
623 // Exclude read only libraries.
624 if( !PROJECT_SCH::SchSymbolLibTable( &prj )->IsSymbolLibWritable( name ) )
625 continue;
626
629 {
630 wxArrayString item;
631
633 itemsToDisplay.push_back( item );
634 }
635 }
636
637 for( const wxString& name : libNicknames )
638 {
639 // Exclude read only libraries.
640 if( !PROJECT_SCH::SchSymbolLibTable( &prj )->IsSymbolLibWritable( name ) )
641 continue;
642
645 {
646 wxArrayString item;
647
648 item.Add( name );
649 itemsToDisplay.push_back( item );
650 }
651 }
652
653 wxString oldLibName = prj.GetRString( PROJECT::SCH_LIB_SELECT );
654
655 EDA_LIST_DIALOG dlg( this, _( "Select Symbol Library" ), headers, itemsToDisplay, oldLibName,
656 false );
657
658 if( dlg.ShowModal() != wxID_OK )
659 return wxEmptyString;
660
661 wxString libName = dlg.GetTextSelection();
662
663 if( !libName.empty() )
664 {
665 if( PROJECT_SCH::SchSymbolLibTable( &prj )->HasLibrary( libName ) )
666 prj.SetRString( PROJECT::SCH_LIB_SELECT, libName );
667 else
668 libName = wxEmptyString;
669 }
670
671 return libName;
672}
673
674
676{
677 Unbind( wxEVT_FSWATCHER, &SCH_BASE_FRAME::OnSymChange, this );
678
679 if( m_watcher )
680 {
681 wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" );
682 m_watcher->RemoveAll();
683 m_watcher->SetOwner( nullptr );
684 m_watcher.reset();
685 }
686
687 wxString libfullname;
689
690 if( !aID || !tbl )
691 return;
692
693 try
694 {
695 const SYMBOL_LIB_TABLE_ROW* row = tbl->FindRow( aID->GetLibNickname() );
696
697 if( !row )
698 return;
699
700 libfullname = row->GetFullURI( true );
701 }
702 catch( const std::exception& e )
703 {
704 DisplayInfoMessage( this, e.what() );
705 return;
706 }
707 catch( const IO_ERROR& error )
708 {
709 wxLogTrace( "KICAD_LIB_WATCH", "Error: %s", error.What() );
710 return;
711 }
712
713 wxLogTrace( "KICAD_LIB_WATCH", "Setting up watcher for %s", libfullname );
714 m_watcherFileName.Assign( libfullname );
715
716 if( !m_watcherFileName.FileExists() )
717 return;
718
719 wxLog::EnableLogging( false );
720 m_watcherLastModified = m_watcherFileName.GetModificationTime();
721 wxLog::EnableLogging( true );
722
723 Bind( wxEVT_FSWATCHER, &SCH_BASE_FRAME::OnSymChange, this );
724 m_watcher = std::make_unique<wxFileSystemWatcher>();
725 m_watcher->SetOwner( this );
726
727 wxFileName fn;
728 fn.AssignDir( m_watcherFileName.GetPath() );
729 fn.DontFollowLink();
730
731 {
732 // Silence OS errors that come from the watcher
733 wxLogNull silence;
734 m_watcher->Add( fn );
735 }
736}
737
738
739void SCH_BASE_FRAME::OnSymChange( wxFileSystemWatcherEvent& aEvent )
740{
742
743 wxLogTrace( "KICAD_LIB_WATCH", "OnSymChange: %s, watcher file: %s",
744 aEvent.GetPath().GetFullPath(), m_watcherFileName.GetFullPath() );
745
746 if( !libs || !m_watcher || !m_watcher.get() || m_watcherFileName.GetPath().IsEmpty() )
747 return;
748
749 if( aEvent.GetPath() != m_watcherFileName )
750 return;
751
752 // Start the debounce timer (set to 1 second)
753 if( !m_watcherDebounceTimer.StartOnce( 1000 ) )
754 {
755 wxLogTrace( "KICAD_LIB_WATCH", "Failed to start the debounce timer" );
756 return;
757 }
758}
759
760
762{
763 if( aEvent.GetId() != m_watcherDebounceTimer.GetId() )
764 {
765 aEvent.Skip();
766 return;
767 }
768
770 {
771 wxLogTrace( "KICAD_LIB_WATCH", "Restarting debounce timer" );
772 m_watcherDebounceTimer.StartOnce( 3000 );
773 }
774
775 wxLogTrace( "KICAD_LIB_WATCH", "OnSymChangeDebounceTimer" );
776
777 // Disable logging to avoid spurious messages and check if the file has changed
778 wxLog::EnableLogging( false );
779 wxDateTime lastModified = m_watcherFileName.GetModificationTime();
780 wxLog::EnableLogging( true );
781
782 if( lastModified == m_watcherLastModified || !lastModified.IsValid() )
783 return;
784
785 m_watcherLastModified = lastModified;
786
788
790 || IsOK( this, _( "The library containing the current symbol has changed.\n"
791 "Do you want to reload the library?" ) ) )
792 {
793 wxLogTrace( "KICAD_LIB_WATCH", "Sending refresh symbol mail" );
794 std::string libName = m_watcherFileName.GetFullPath().ToStdString();
797 }
798
800}
801
802
804{
805 if( m_toolManager )
807
808 return nullptr;
809}
const char * name
Definition: DXF_plotter.cpp:62
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:108
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:237
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
int ShowModal() override
FRAME_T GetFrameType() const
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
virtual bool IsContentModified() const
Get if the contents of the frame have been modified since the last save.
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
The base class for create windows for drawing purpose.
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
COLOR_SETTINGS * m_colorSettings
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void DisplayUnitsMsg()
Display current unit pane in the status bar.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting(APP_SETTINGS_BASE *aCfg=nullptr)
Return the canvas type stored in the application settings.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
void UpdateStatusBar() override
Update the status bar information.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void DisplayGridMsg()
Display current grid size in the status bar.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:97
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:109
EDA_ITEM * GetParent() const
Definition: eda_item.h:111
A dialog which shows:
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
double GetWorldScale() const
Get the world scale.
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:59
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
static std::vector< KICAD_T > g_ScaledSelectionTypes
Definition: sch_painter.h:147
void Update(const KIGFX::VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: sch_view.cpp:60
virtual void CenterOnCursor()=0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:297
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:331
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:198
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1441
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1551
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:216
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:586
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:635
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:286
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:499
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
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
Define a library symbol object.
Definition: lib_symbol.h:85
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static const wxString GetPinningSymbol()
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:171
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:565
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
Definition: project_file.h:139
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
static SYMBOL_LIBS * SchLibs(PROJECT *aProject)
These are all prefaced with "Sch".
Definition: project_sch.cpp:90
Container for project specific data.
Definition: project.h:65
@ SCH_LIB_SELECT
Definition: project.h:221
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:204
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:320
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:331
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void RedrawScreen(const VECTOR2I &aCenterPoint, bool aWarpPointer)
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
void UpdateStatusBar() override
Update the status bar information.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen) override
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
SCH_RENDER_SETTINGS * GetRenderSettings()
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
void OnSymChange(wxFileSystemWatcherEvent &aEvent)
Handler for Symbol change events.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SYMBOL_EDITOR_SETTINGS * libeditconfig() const
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
APP_SETTINGS_BASE * GetViewerSettingsBase() const
void HardRedraw() override
Rebuild the GAL and redraws the screen.
wxTimer m_watcherDebounceTimer
SYMBOL_LIB_TABLE * SelectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
SCH_SELECTION_TOOL * GetSelectionTool() override
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
void SyncView()
Mark all items for refresh.
std::unique_ptr< NL_SCHEMATIC_PLUGIN > m_spaceMouse
wxDateTime m_watcherLastModified
std::unique_ptr< wxFileSystemWatcher > m_watcher
These are file watchers for the symbol library tables.
bool m_inSymChangeTimerEvent
virtual ~SCH_BASE_FRAME()
Needs to be in the cpp file to encode the sizeof() for std::unique_ptr.
const TITLE_BLOCK & GetTitleBlock() const override
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
void RefreshZoomDependentItems()
Mark selected items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
wxFileName m_watcherFileName
void setSymWatcher(const LIB_ID *aSymbol)
Creates (or removes) a watcher on the specified symbol library.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr) override
Add an item to the screen (and view) aScreen is the screen the item is located on,...
const PAGE_INFO & GetPageSettings() const override
COLOR4D GetDrawBgColor() const override
void OnSymChangeDebounceTimer(wxTimerEvent &aEvent)
Handler for the filesystem watcher debounce timer.
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
A set of SCH_ITEMs (i.e., without duplicates).
Definition: sch_group.h:52
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:134
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:160
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:160
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:135
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:158
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:323
SCH_SELECTION & GetSelection()
void OnIdle(wxIdleEvent &aEvent)
Zoom the screen to fit the bounding box for cross probing/selection sync.
A collection of SYMBOL_LIB objects.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
static const wxString GetSymbolLibTableFileName()
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
Object used to load, save, search, and otherwise manipulate symbol library files.
bool IsCache() const
LIB_SYMBOL * FindSymbol(const wxString &aName) const
Find LIB_SYMBOL by aName.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString wx_str() const
Definition: utf8.cpp:45
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:251
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:222
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
This file is part of the common library.
#define _(s)
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ 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_SYMBOL_CHOOSER
Definition: frame_type.h:37
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:439
@ LAYER_SCHEMATIC_GRID_AXES
Definition: layer_ids.h:477
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:478
@ MAIL_REFRESH_SYMBOL
Definition: mail_type.h:59
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:58
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:59
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:38
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
Declaration of the NL_SCHEMATIC_PLUGIN class.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
see class PGM_BASE
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, SYMBOL_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, SYMBOL_LIB *aCacheLib=nullptr, wxWindow *aParent=nullptr, bool aShowErrorMsg=false)
Load symbol from symbol library table.
Class to handle a set of SCH_ITEMs.
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< wxString > pinned_symbol_libs
const double IU_PER_MILS
Definition: base_units.h:77
Definition for symbol library class.
@ SCH_TABLE_T
Definition: typeinfo.h:166
@ SCH_SYMBOL_T
Definition: typeinfo.h:173
@ SCH_TABLECELL_T
Definition: typeinfo.h:167
@ SCH_SHEET_T
Definition: typeinfo.h:176
@ SCH_SHAPE_T
Definition: typeinfo.h:150
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:192
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:175