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 (C) 2015-2023 KiCad Developers, see change_log.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_view.h>
37#include <sch_painter.h>
39#include <confirm.h>
41#include <project_sch.h>
42#include <symbol_library.h>
43#include <sch_base_frame.h>
44#include <symbol_lib_table.h>
45#include <tool/action_toolbar.h>
46#include <tool/tool_manager.h>
48#include <tools/ee_actions.h>
50#include <wx/choicdlg.h>
51#include <wx/log.h>
52
54
56 SYMBOL_LIB* aCacheLib, wxWindow* aParent, bool aShowErrorMsg )
57{
58 wxCHECK_MSG( aLibTable, nullptr, wxS( "Invalid symbol library table." ) );
59
60 LIB_SYMBOL* symbol = nullptr;
61
62 try
63 {
64 symbol = aLibTable->LoadSymbol( aLibId );
65
66 if( !symbol && aCacheLib )
67 {
68 wxCHECK_MSG( aCacheLib->IsCache(), nullptr, wxS( "Invalid cache library." ) );
69
70 wxString cacheName = aLibId.GetLibNickname().wx_str();
71 cacheName += "_" + aLibId.GetLibItemName();
72 symbol = aCacheLib->FindSymbol( cacheName );
73 }
74 }
75 catch( const IO_ERROR& ioe )
76 {
77 if( aShowErrorMsg )
78 {
79 wxString msg = wxString::Format( _( "Error loading symbol %s from library '%s'." ),
80 aLibId.GetLibItemName().wx_str(),
81 aLibId.GetLibNickname().wx_str() );
82 DisplayErrorMessage( aParent, msg, ioe.What() );
83 }
84 }
85
86 return symbol;
87}
88
89
90SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindowType,
91 const wxString& aTitle, const wxPoint& aPosition,
92 const wxSize& aSize, long aStyle, const wxString& aFrameName ) :
93 EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle,
94 aFrameName, schIUScale ),
95 m_base_frame_defaults( nullptr, "base_Frame_defaults" ), m_spaceMouse( nullptr )
96{
97 if( ( aStyle & wxFRAME_NO_TASKBAR ) == 0 )
99
100 Bind( wxEVT_IDLE,
101 [this]( wxIdleEvent& aEvent )
102 {
103 // Handle cursor adjustments. While we can get motion and key events through
104 // wxWidgets, we can't get modifier-key-up events.
105 if( m_toolManager )
106 {
108
109 if( selTool )
110 selTool->OnIdle( aEvent );
111 }
112 } );
113
115}
116
117
119{
120 delete m_spaceMouse;
121}
122
123
125{
127}
128
129
131{
132 return dynamic_cast<EESCHEMA_SETTINGS*>( config() );
133}
134
135
137{
138 return dynamic_cast<SYMBOL_EDITOR_SETTINGS*>( config() );
139}
140
141
142void SCH_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
143{
144 GetScreen()->SetPageSettings( aPageSettings );
145}
146
147
149{
150 return GetScreen()->GetPageSettings();
151}
152
153
155{
156 // GetSizeIU is compile time dependent:
158}
159
160
162{
163 wxASSERT( GetScreen() );
164 return GetScreen()->GetTitleBlock();
165}
166
167
169{
170 wxASSERT( GetScreen() );
171 GetScreen()->SetTitleBlock( aTitleBlock );
172}
173
174
176{
177 wxString line;
178 BASE_SCREEN* screen = GetScreen();
179
180 if( !screen )
181 return;
182
184
185 // Display absolute and relative coordinates
187 VECTOR2D d = cursorPos - screen->m_LocalOrigin;
188
189 line.Printf( wxS( "X %s Y %s" ),
190 MessageTextFromValue( cursorPos.x, false ),
191 MessageTextFromValue( cursorPos.y, false ) );
192 SetStatusText( line, 2 );
193
194 line.Printf( wxS( "dx %s dy %s dist %s" ),
195 MessageTextFromValue( d.x, false ),
196 MessageTextFromValue( d.y, false ),
197 MessageTextFromValue( hypot( d.x, d.y ), false ) );
198 SetStatusText( line, 3 );
199
202}
203
204
205LIB_SYMBOL* SCH_BASE_FRAME::GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib,
206 bool aShowErrorMsg )
207{
208 SYMBOL_LIB* cache =
209 ( aUseCacheLib ) ? PROJECT_SCH::SchLibs( &Prj() )->GetCacheLibrary() : nullptr;
210
211 return SchGetLibSymbol( aLibId, PROJECT_SCH::SchSymbolLibTable( &Prj() ), cache, this,
212 aShowErrorMsg );
213}
214
215
216bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
217{
218 wxString msg;
219 bool success = true;
220
221 if( aGlobal )
222 {
223 try
224 {
226 }
227 catch( const IO_ERROR& ioe )
228 {
229 success = false;
230 msg.Printf( _( "Error saving global symbol library table:\n%s" ), ioe.What() );
231 DisplayErrorMessage( this, msg );
232 }
233 }
234
235 if( aProject && !Prj().GetProjectName().IsEmpty() )
236 {
237 wxFileName fn( Prj().GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
238
239 try
240 {
241 PROJECT_SCH::SchSymbolLibTable( &Prj() )->Save( fn.GetFullPath() );
242 }
243 catch( const IO_ERROR& ioe )
244 {
245 success = false;
246 msg.Printf( _( "Error saving project-specific symbol library table:\n%s" ),
247 ioe.What() );
248 DisplayErrorMessage( this, msg );
249 }
250 }
251
252 return success;
253}
254
255
257{
258 // If no project is loaded, always work with the global table
259 if( Prj().IsNullProject() )
260 {
262
263 if( aOptional )
264 {
265 wxMessageDialog dlg( this, _( "Add the library to the global library table?" ),
266 _( "Add To Global Library Table" ), wxYES_NO );
267
268 if( dlg.ShowModal() != wxID_OK )
269 ret = nullptr;
270 }
271
272 return ret;
273 }
274
275 wxArrayString libTableNames;
276 libTableNames.Add( _( "Global" ) );
277 libTableNames.Add( _( "Project" ) );
278
279 wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
280 _( "Add To Library Table" ), libTableNames );
281
282 if( aOptional )
283 {
284 dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
285 dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
286 }
287
288 if( dlg.ShowModal() != wxID_OK )
289 return nullptr;
290
291 switch( dlg.GetSelection() )
292 {
293 case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
294 case 1: return PROJECT_SCH::SchSymbolLibTable( &Prj() );
295 default: return nullptr;
296 }
297}
298
299
300void SCH_BASE_FRAME::RedrawScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer )
301{
302 GetCanvas()->GetView()->SetCenter( aCenterPoint );
303
304 if( aWarpPointer )
306
307 GetCanvas()->Refresh();
308}
309
310
312{
313 if( GetCanvas() && GetCanvas()->GetView() )
314 {
317 }
318}
319
320
322{
323 return static_cast<SCH_DRAW_PANEL*>( EDA_DRAW_FRAME::GetCanvas() );
324}
325
326
328{
329 if( GetCanvas() && GetCanvas()->GetView() )
330 {
331 if( KIGFX::PAINTER* painter = GetCanvas()->GetView()->GetPainter() )
332 return static_cast<KIGFX::SCH_RENDER_SETTINGS*>( painter->GetSettings() );
333 }
334
335 return nullptr;
336}
337
338
340{
342
343 SetCanvas( new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_frameSize,
346}
347
348
350{
352
353 try
354 {
355 if( !m_spaceMouse )
357
359 }
360 catch( const std::system_error& e )
361 {
362 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
363 }
364}
365
366
367void SCH_BASE_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
368{
369 EDA_ITEM* parent = aItem->GetParent();
370
371 if( aItem->Type() == SCH_SHEET_PIN_T )
372 {
373 // Sheet pins aren't in the view. Refresh their parent.
374 if( parent )
375 GetCanvas()->GetView()->Update( parent );
376 }
377 else
378 {
379 if( !isAddOrDelete )
380 GetCanvas()->GetView()->Update( aItem );
381
382 // Some children are drawn from their parents. Mark them for re-paint.
383 if( parent && parent->IsType( { SCH_SYMBOL_T, SCH_SHEET_T, SCH_LABEL_LOCATE_ANY_T } ) )
384 GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT );
385 }
386
391 if( aUpdateRtree && dynamic_cast<SCH_ITEM*>( aItem ) )
392 GetScreen()->Update( static_cast<SCH_ITEM*>( aItem ) );
393
394 // Calling Refresh() here introduces a bi-stable state: when doing operations on a
395 // large number of items if at some point the refresh timer times out and does a
396 // refresh it will take long enough that the next item will also time out, and the
397 // next, and the next, etc.
398 // GetCanvas()->Refresh();
399}
400
401
403{
404 // We currently have two zoom-dependent renderings: text, which is rendered as bitmap text
405 // when too small to see the difference, and selection shadows.
406 //
407 // Because non-selected text is cached by OpenGL, we only apply the bitmap performance hack
408 // to selected text items.
409 //
410 // Thus, as it currently stands, all zoom-dependent items can be found in the list of selected
411 // items.
412
413 if( m_toolManager )
414 {
416 SELECTION& selection = selectionTool->GetSelection();
417 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
418
419 for( EDA_ITEM* item : selection )
420 {
421 if( item->RenderAsBitmap( view->GetGAL()->GetWorldScale() ) != item->IsShownAsBitmap()
423 {
424 view->Update( item, KIGFX::REPAINT );
425
426 EDA_ITEM* parent = item->GetParent();
427
428 // Symbol children are drawn from their parents. Mark them for re-paint.
429 if( parent && parent->Type() == SCH_SYMBOL_T )
430 GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT );
431 }
432 }
433 }
434}
435
436
438{
439 // Null pointers will cause boost::ptr_vector to raise a boost::bad_pointer exception which
440 // will be unhandled. There is no valid reason to pass an invalid EDA_ITEM pointer to the
441 // screen append function.
442 wxCHECK( aItem != nullptr, /* void */ );
443
444 auto screen = aScreen;
445
446 if( aScreen == nullptr )
447 screen = GetScreen();
448
449 screen->Append( (SCH_ITEM*) aItem );
450
451 if( screen == GetScreen() )
452 {
453 GetCanvas()->GetView()->Add( aItem );
454 UpdateItem( aItem, true ); // handle any additional parent semantics
455 }
456}
457
458
460{
461 auto screen = aScreen;
462
463 if( aScreen == nullptr )
464 screen = GetScreen();
465
466 if( screen == GetScreen() )
467 GetCanvas()->GetView()->Remove( aItem );
468
469 screen->Remove( (SCH_ITEM*) aItem );
470
471 if( screen == GetScreen() )
472 UpdateItem( aItem, true ); // handle any additional parent semantics
473}
474
475
477{
478 // Let tools add things to the view if necessary
479 if( m_toolManager )
481
483}
484
485
487{
488 return GetColorSettings()->GetColor( aLayer );
489}
490
491
492void SCH_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
493{
494 EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
495
496 COLOR_SETTINGS* colorSettings = GetColorSettings( true );
497
498 GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( colorSettings );
500
504}
505
506
508{
509 if( !m_colorSettings || aForceRefresh )
510 {
511 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
513 wxString colorTheme = cfg->m_ColorTheme;
514
516 {
518
519 if( !symCfg->m_UseEeschemaColorSettings )
520 colorTheme = symCfg->m_ColorTheme;
521 }
522
523 COLOR_SETTINGS* colorSettings = mgr.GetColorSettings( colorTheme );
524
525 const_cast<SCH_BASE_FRAME*>( this )->m_colorSettings = colorSettings;
526 }
527
528 return m_colorSettings;
529}
530
531
533{
535}
536
537
538void SCH_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
539{
541
542 if( m_spaceMouse )
543 m_spaceMouse->SetFocus( aEvent.GetActive() );
544}
545
546
547void SCH_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
548{
550
551 if( m_spaceMouse )
552 m_spaceMouse->SetFocus( false );
553}
554
555
557{
558 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
559 PROJECT& prj = Prj();
560
561 if( PROJECT_SCH::SchSymbolLibTable( &prj )->IsEmpty() )
562 {
563 ShowInfoBarError( _( "No symbol libraries are loaded." ) );
564 return wxEmptyString;
565 }
566
567 wxArrayString headers;
568
569 headers.Add( _( "Library" ) );
570
571 std::vector< wxArrayString > itemsToDisplay;
572 std::vector< wxString > libNicknames = PROJECT_SCH::SchSymbolLibTable( &prj )->GetLogicalLibs();
573
574 for( const wxString& name : libNicknames )
575 {
576 // Exclude read only libraries.
577 if( !PROJECT_SCH::SchSymbolLibTable( &prj )->IsSymbolLibWritable( name ) )
578 continue;
579
582 {
583 wxArrayString item;
584
586 itemsToDisplay.push_back( item );
587 }
588 }
589
590 for( const wxString& name : libNicknames )
591 {
592 // Exclude read only libraries.
593 if( !PROJECT_SCH::SchSymbolLibTable( &prj )->IsSymbolLibWritable( name ) )
594 continue;
595
598 {
599 wxArrayString item;
600
601 item.Add( name );
602 itemsToDisplay.push_back( item );
603 }
604 }
605
606 wxString oldLibName = prj.GetRString( PROJECT::SCH_LIB_SELECT );
607
608 EDA_LIST_DIALOG dlg( this, _( "Select Symbol Library" ), headers, itemsToDisplay, oldLibName,
609 false );
610
611 if( dlg.ShowModal() != wxID_OK )
612 return wxEmptyString;
613
614 wxString libName = dlg.GetTextSelection();
615
616 if( !libName.empty() )
617 {
618 if( PROJECT_SCH::SchSymbolLibTable( &prj )->HasLibrary( libName ) )
619 prj.SetRString( PROJECT::SCH_LIB_SELECT, libName );
620 else
621 libName = wxEmptyString;
622 }
623
624 return libName;
625}
626
627
629{
630 Unbind( wxEVT_FSWATCHER, &SCH_BASE_FRAME::OnSymChange, this );
631
632 if( m_watcher )
633 {
634 wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" );
635 m_watcher->RemoveAll();
636 m_watcher->SetOwner( nullptr );
637 m_watcher.reset();
638 }
639
640 wxString libfullname;
642
643 if( !aID || !tbl )
644 return;
645
646 try
647 {
648 const SYMBOL_LIB_TABLE_ROW* row = tbl->FindRow( aID->GetLibNickname() );
649
650 if( !row )
651 return;
652
653 libfullname = row->GetFullURI( true );
654 }
655 catch( const std::exception& e )
656 {
657 DisplayInfoMessage( this, e.what() );
658 return;
659 }
660 catch( const IO_ERROR& error )
661 {
662 wxLogTrace( "KICAD_LIB_WATCH", "Error: %s", error.What() );
663 return;
664 }
665
666 wxLogTrace( "KICAD_LIB_WATCH", "Setting up watcher for %s", libfullname );
667 m_watcherFileName.Assign( libfullname );
668
669 if( !m_watcherFileName.FileExists() )
670 return;
671
672 wxLog::EnableLogging( false );
673 m_watcherLastModified = m_watcherFileName.GetModificationTime();
674 wxLog::EnableLogging( true );
675
676 Bind( wxEVT_FSWATCHER, &SCH_BASE_FRAME::OnSymChange, this );
677 m_watcher = std::make_unique<wxFileSystemWatcher>();
678 m_watcher->SetOwner( this );
679
680 wxFileName fn;
681 fn.AssignDir( m_watcherFileName.GetPath() );
682 fn.DontFollowLink();
683
684 m_watcher->AddTree( fn );
685}
686
687
688void SCH_BASE_FRAME::OnSymChange( wxFileSystemWatcherEvent& aEvent )
689{
691
692 wxLogTrace( "KICAD_LIB_WATCH", "OnSymChange: %s, watcher file: %s",
693 aEvent.GetPath().GetFullPath(), m_watcherFileName.GetFullPath() );
694
695 if( !libs || !m_watcher || !m_watcher.get() || m_watcherFileName.GetPath().IsEmpty() )
696 return;
697
698 if( aEvent.GetPath() != m_watcherFileName )
699 return;
700
701 // Start the debounce timer (set to 1 second)
702 if( !m_watcherDebounceTimer.StartOnce( 1000 ) )
703 {
704 wxLogTrace( "KICAD_LIB_WATCH", "Failed to start the debounce timer" );
705 return;
706 }
707}
708
709
711{
712 wxLogTrace( "KICAD_LIB_WATCH", "OnSymChangeDebounceTimer" );
713 // Disable logging to avoid spurious messages and check if the file has changed
714 wxLog::EnableLogging( false );
715 wxDateTime lastModified = m_watcherFileName.GetModificationTime();
716 wxLog::EnableLogging( true );
717
718 if( lastModified == m_watcherLastModified || !lastModified.IsValid() )
719 return;
720
721 m_watcherLastModified = lastModified;
722
723 if( !GetScreen()->IsContentModified() || IsOK( this, _( "The library containing the current symbol has changed.\n"
724 "Do you want to reload the library?" ) ) )
725 {
726 wxLogTrace( "KICAD_LIB_WATCH", "Sending refresh symbol mail" );
727 std::string libName = m_watcherFileName.GetFullPath().ToStdString();
730 }
731}
const char * name
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:172
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
virtual APP_SETTINGS_BASE * config() const
Returns 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
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)
Returns 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.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void DisplayGridMsg()
Display current grid size in the status bar.
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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:172
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
A dialog which shows:
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void OnIdle(wxIdleEvent &aEvent)
Zoom the screen to fit the bounding box for cross probing/selection sync.
EE_SELECTION & GetSelection()
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:209
Store schematic specific render settings.
Definition: sch_painter.h:71
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:313
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1618
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:197
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1400
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1500
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:573
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:619
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:279
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:553
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:99
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()
The class that implements the public interface to the SpaceMouse plug-in.
void SetFocus(bool aFocus)
Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed to thi...
void SetCanvas(EDA_DRAW_PANEL_GAL *aViewport)
Sets the viewport controlled by the SpaceMouse.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:58
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:170
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
Definition: project_file.h:120
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
static SYMBOL_LIBS * SchLibs(PROJECT *aProject)
Definition: project_sch.cpp:90
Container for project specific data.
Definition: project.h:62
@ SCH_LIB_SELECT
Definition: project.h:183
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:166
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:277
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:288
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 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 AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
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.
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.
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
void SyncView()
Mark all items for refresh.
wxDateTime m_watcherLastModified
std::unique_ptr< wxFileSystemWatcher > m_watcher
These are file watchers for the symbol library tables.
virtual ~SCH_BASE_FRAME()
const TITLE_BLOCK & GetTitleBlock() const override
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
NL_SCHEMATIC_PLUGIN * m_spaceMouse
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.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
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.
const PAGE_INFO & GetPageSettings() const override
COLOR4D GetDrawBgColor() const override
void OnSymChangeDebounceTimer(wxTimerEvent &aEvent)
Handler for the filesystem watcher debounce timer.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
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.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:131
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:157
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:132
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:155
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:312
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
A collection of SYMBOL_LIB objects.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
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:165
@ 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:360
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:332
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:305
This file is part of the common library.
#define _(s)
FRAME_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
KIWAY Kiway
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:346
@ LAYER_SCHEMATIC_GRID_AXES
Definition: layer_ids.h:381
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:382
@ MAIL_REFRESH_SYMBOL
Definition: mail_type.h:58
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:58
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
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.
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.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
std::vector< wxString > pinned_symbol_libs
const double IU_PER_MILS
Definition: base_units.h:78
Definition for symbol library class.
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157