KiCad PCB EDA Suite
eda_draw_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) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <base_screen.h>
27#include <bitmaps.h>
28#include <confirm.h>
29#include <core/arraydim.h>
30#include <dialog_shim.h>
31#include <eda_draw_frame.h>
32#include <file_history.h>
33#include <id.h>
34#include <kiface_base.h>
35#include <lockfile.h>
36#include <macros.h>
37#include <page_info.h>
38#include <paths.h>
39#include <pgm_base.h>
40#include <render_settings.h>
45#include <title_block.h>
46#include <tool/actions.h>
47#include <tool/common_tools.h>
48#include <tool/grid_menu.h>
51#include <tool/tool_manager.h>
52#include <tool/tool_menu.h>
53#include <tool/zoom_menu.h>
54#include <trace_helpers.h>
55#include <view/view.h>
57#include <widgets/msgpanel.h>
58#include <wx/event.h>
59#include <wx/snglinst.h>
61#include <widgets/ui_common.h>
62#include <widgets/search_pane.h>
63#include <wx/dirdlg.h>
64#include <wx/filedlg.h>
65#include <wx/msgdlg.h>
66#include <wx/socket.h>
67
68#include <wx/snglinst.h>
69#include <wx/fdrepdlg.h>
70
71#define FR_HISTORY_LIST_CNT 10
72
73
74BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
77
78 EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate )
79END_EVENT_TABLE()
80
81bool EDA_DRAW_FRAME::m_openGLFailureOccured = false;
82
83EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
84 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
85 long aStyle, const wxString& aFrameName, const EDA_IU_SCALE& aIuScale ) :
86 KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, aIuScale )
87{
88 m_socketServer = nullptr;
89 m_mainToolBar = nullptr;
90 m_drawToolBar = nullptr;
91 m_optionsToolBar = nullptr;
92 m_auxiliaryToolBar = nullptr;
93 m_gridSelectBox = nullptr;
94 m_zoomSelectBox = nullptr;
95 m_searchPane = nullptr;
96 m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
97
99 m_canvas = nullptr;
100 m_toolDispatcher = nullptr;
101 m_messagePanel = nullptr;
102 m_currentScreen = nullptr;
103 m_showBorderAndTitleBlock = false; // true to display reference sheet.
104 m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
105 m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
106 // BLACK for Pcbnew, BLACK or WHITE for Eeschema
107 m_colorSettings = nullptr;
108 m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
109 m_polarCoords = false;
110 m_findReplaceData = std::make_unique<EDA_SEARCH_DATA>();
111
112 SetUserUnits( EDA_UNITS::MILLIMETRES );
113
114 m_auimgr.SetFlags( wxAUI_MGR_DEFAULT );
115
116 CreateStatusBar( 8 )->SetDoubleBuffered( true );
117
118 // set the size of the status bar subwindows:
119
120 wxWindow* stsbar = GetStatusBar();
121 int spacer = KIUI::GetTextSize( wxT( "M" ), stsbar ).x * 2;
122
123 int dims[] = {
124
125 // remainder of status bar on far left is set to a default or whatever is left over.
126 -1,
127
128 // When using GetTextSize() remember the width of character '1' is not the same
129 // as the width of '0' unless the font is fixed width, and it usually won't be.
130
131 // zoom:
132 KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + spacer,
133
134 // cursor coords
135 KIUI::GetTextSize( wxT( "X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer,
136
137 // delta distances
138 KIUI::GetTextSize( wxT( "dx 1234.1234 dy 1234.1234 dist 1234.1234" ), stsbar ).x + spacer,
139
140 // grid size
141 KIUI::GetTextSize( wxT( "grid X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer,
142
143 // units display, Inches is bigger than mm
144 KIUI::GetTextSize( _( "Inches" ), stsbar ).x + spacer,
145
146 // Size for the "Current Tool" panel; longest string from SetTool()
147 KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + spacer,
148
149 // constraint mode
150 KIUI::GetTextSize( _( "Constrain to H, V, 45" ), stsbar ).x + spacer
151 };
152
153 SetStatusWidths( arrayDim( dims ), dims );
154 stsbar->SetFont( KIUI::GetStatusFont( this ) );
155
156 // Create child subwindows.
157 GetClientSize( &m_frameSize.x, &m_frameSize.y );
158 m_framePos.x = m_framePos.y = 0;
159 m_frameSize.y -= m_msgFrameHeight;
160
161 m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ),
162 wxSize( m_frameSize.x, m_msgFrameHeight ) );
163
164 m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
165
166#if wxCHECK_VERSION( 3, 1, 3 )
167 Bind( wxEVT_DPI_CHANGED,
168 [&]( wxDPIChangedEvent& )
169 {
170 wxMoveEvent dummy;
171 OnMove( dummy );
172
173 // we need to kludge the msg panel to the correct size again
174 // especially important even for first launches as the constructor of the window here usually doesn't
175 // have the correct dpi awareness yet
176 m_frameSize.y += m_msgFrameHeight;
177 m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
178 m_frameSize.y -= m_msgFrameHeight;
179
180 m_messagePanel->SetPosition( wxPoint( 0, m_frameSize.y ) );
181 m_messagePanel->SetSize( m_frameSize.x, m_msgFrameHeight );
182 } );
183#endif
184}
185
186
188{
189 delete m_socketServer;
190
191 for( wxSocketBase* socket : m_sockets )
192 {
193 socket->Shutdown();
194 socket->Destroy();
195 }
196
198
199 delete m_actions;
200 delete m_toolManager;
201 delete m_toolDispatcher;
202 delete m_canvas;
203
204 delete m_currentScreen;
205 m_currentScreen = nullptr;
206
207 m_auimgr.UnInit();
208
209 ReleaseFile();
210}
211
212
214{
215 m_file_checker = nullptr;
216}
217
218
219bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
220{
221 m_file_checker = ::LockFile( aFileName );
222
223 return m_file_checker && !m_file_checker->IsAnotherRunning();
224}
225
226
228{
229 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
230
231 wxRect rect = GetScreenRect();
232 wxPoint center = rect.GetPosition() + rect.GetSize() / 2;
233
234 if( !frame )
235 {
236 frame = Kiway().Player( FRAME_PYTHON, true, Kiway().GetTop() );
237
238 // If we received an error in the CTOR due to Python-ness, don't crash
239 if( !frame )
240 return;
241
242 if( !frame->IsVisible() )
243 frame->Show( true );
244
245 // On Windows, Raise() does not bring the window on screen, when iconized
246 if( frame->IsIconized() )
247 frame->Iconize( false );
248
249 frame->Raise();
250 frame->SetPosition( center - frame->GetSize() / 2 );
251
252 return;
253 }
254
255 frame->Show( !frame->IsVisible() );
256 frame->SetPosition( center - frame->GetSize() / 2 );
257}
258
259
261{
262 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
263 return frame && frame->IsVisible();
264}
265
266
268{
269 // Notify all tools the units have changed
270 if( m_toolManager )
272
275}
276
277
279{
281 {
283 m_toolManager->GetTool<COMMON_TOOLS>()->ToggleUnits( dummy );
284 }
285 else
286 {
290
291 wxCommandEvent e( UNITS_CHANGED );
292 ProcessEventLocally( e );
293 }
294}
295
296
297void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
298{
299 EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
300
301 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
303
304 if( m_supportsAutoSave && m_autoSaveTimer->IsRunning() )
305 {
306 if( GetAutoSaveInterval() > 0 )
307 {
308 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
309 }
310 else
311 {
312 m_autoSaveTimer->Stop();
313 m_autoSavePending = false;
314 }
315 }
316
317 viewControls->LoadSettings();
318
319 m_galDisplayOptions.ReadCommonConfig( *settings, this );
320
321#ifndef __WXMAC__
323
324 if( m_canvasType != GetCanvas()->GetBackend() )
325 {
326 // Try to switch (will automatically fallback if necessary)
329 bool success = newGAL == m_canvasType;
330
331 if( !success )
332 {
333 m_canvasType = newGAL;
334 m_openGLFailureOccured = true; // Store failure for other EDA_DRAW_FRAMEs
335 }
336 }
337#endif
338
339 // Notify all tools the preferences have changed
340 if( m_toolManager )
342}
343
344
346{
347 if( m_messagePanel )
349}
350
351
353{
356
357 if( m_gridSelectBox == nullptr )
358 return;
359
360 // Update grid values with the current units setting.
361 m_gridSelectBox->Clear();
362 wxArrayString gridsList;
363
364 wxCHECK( config(), /* void */ );
365
366 GRID_MENU::BuildChoiceList( &gridsList, config(), this );
367
368 for( const wxString& grid : gridsList )
369 m_gridSelectBox->Append( grid );
370
371 m_gridSelectBox->Append( wxT( "---" ) );
372 m_gridSelectBox->Append( _( "Edit User Grid..." ) );
373
374 m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx );
375}
376
377
378void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
379{
380 // No need to update the grid select box if it doesn't exist or the grid setting change
381 // was made using the select box.
382 if( m_gridSelectBox == nullptr )
383 return;
384
385 wxCHECK( config(), /* void */ );
386
387 int idx = config()->m_Window.grid.last_size_idx;
388 idx = std::max( 0, std::min( idx, (int) m_gridSelectBox->GetCount() - 1 ) );
389
390 if( idx != m_gridSelectBox->GetSelection() )
391 m_gridSelectBox->SetSelection( idx );
392}
393
394
395
396void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
397{
398 // No need to update the grid select box if it doesn't exist or the grid setting change
399 // was made using the select box.
400 if( m_zoomSelectBox == nullptr )
401 return;
402
403 double zoom = GetCanvas()->GetGAL()->GetZoomFactor();
404
405 wxCHECK( config(), /* void */ );
406
407 const std::vector<double>& zoomList = config()->m_Window.zoom_factors;
408 int curr_selection = m_zoomSelectBox->GetSelection();
409 int new_selection = 0; // select zoom auto
410 double last_approx = 1e9; // large value to start calculation
411
412 // Search for the nearest available value to the current zoom setting, and select it
413 for( size_t jj = 0; jj < zoomList.size(); ++jj )
414 {
415 double rel_error = std::fabs( zoomList[jj] - zoom ) / zoom;
416
417 if( rel_error < last_approx )
418 {
419 last_approx = rel_error;
420 // zoom IDs in m_zoomSelectBox start with 1 (leaving 0 for auto-zoom choice)
421 new_selection = jj+1;
422 }
423 }
424
425 if( curr_selection != new_selection )
426 m_zoomSelectBox->SetSelection( new_selection );
427}
428
430{
431 DisplayErrorMessage( this, wxT("EDA_DRAW_FRAME::PrintPage() error") );
432}
433
434
435void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
436{
437 wxCHECK_RET( m_gridSelectBox, wxS( "m_gridSelectBox uninitialized" ) );
438
439 int idx = m_gridSelectBox->GetCurrentSelection();
440
441 if( idx == int( m_gridSelectBox->GetCount() ) - 2 )
442 {
443 // wxWidgets will check the separator, which we don't want.
444 // Re-check the current grid.
445 wxUpdateUIEvent dummy;
447 }
448 else if( idx == int( m_gridSelectBox->GetCount() ) - 1 )
449 {
450 // wxWidgets will check the Grid Settings... entry, which we don't want.
451 // Re-check the current grid.
452 wxUpdateUIEvent dummy;
454
455 // Give a time-slice to close the menu before opening the dialog.
456 // (Only matters on some versions of GTK.)
457 wxSafeYield();
458
460 }
461 else
462 {
463 m_toolManager->RunAction( ACTIONS::gridPreset, true, static_cast<intptr_t>( idx ) );
464 }
465
467 m_canvas->Refresh();
468 // Needed on Windows because clicking on m_gridSelectBox remove the focus from m_canvas
469 // (Windows specific
471}
472
473
474void EDA_DRAW_FRAME::OnGridSettings( wxCommandEvent& aEvent )
475{
476 DIALOG_GRID_SETTINGS dlg( this );
477
478 if( dlg.ShowModal() == wxID_OK )
479 {
481 GetCanvas()->Refresh();
482 }
483}
484
485
487{
488 wxCHECK( config(), true );
489
490 return config()->m_Window.grid.show;
491}
492
493
495{
496 wxCHECK( config(), /* void */ );
497
498 config()->m_Window.grid.show = aVisible;
499
500 // Update the display with the new grid
501 if( GetCanvas() )
502 {
503 // Check to ensure these exist, since this function could be called before
504 // the GAL and View have been created
505 if( GetCanvas()->GetGAL() )
506 GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
507
508 if( GetCanvas()->GetView() )
510
511 GetCanvas()->Refresh();
512 }
513}
514
515
517{
518 if( m_zoomSelectBox == nullptr )
519 return;
520
521 double zoom = m_canvas->GetGAL()->GetZoomFactor();
522
523 m_zoomSelectBox->Clear();
524 m_zoomSelectBox->Append( _( "Zoom Auto" ) );
525 m_zoomSelectBox->SetSelection( 0 );
526
527 wxCHECK( config(), /* void */ );
528
529 for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i )
530 {
531 double current = config()->m_Window.zoom_factors[i];
532
533 m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) );
534
535 if( zoom == current )
536 m_zoomSelectBox->SetSelection( i + 1 );
537 }
538}
539
540
541void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
542{
543 wxCHECK_RET( m_zoomSelectBox, wxS( "m_zoomSelectBox uninitialized" ) );
544
545 int id = m_zoomSelectBox->GetCurrentSelection();
546
547 if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
548 return;
549
550 m_toolManager->RunAction( ACTIONS::zoomPreset, true, static_cast<intptr_t>( id ) );
552 m_canvas->Refresh();
553 // Needed on Windows because clicking on m_zoomSelectBox remove the focus from m_canvas
554 // (Windows specific
556}
557
558
559void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
560{
561 // If the window is moved to a different display, the scaling factor may change
562 double oldFactor = m_galDisplayOptions.m_scaleFactor;
564
565 if( oldFactor != m_galDisplayOptions.m_scaleFactor && m_canvas )
566 {
567 wxSize clientSize = GetClientSize();
568 GetCanvas()->GetGAL()->ResizeScreen( clientSize.x, clientSize.y );
570 }
571
572 aEvent.Skip();
573}
574
575
577{
579 CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
580
581 aMenu.AddSeparator( 1000 );
582
583 std::shared_ptr<ZOOM_MENU> zoomMenu = std::make_shared<ZOOM_MENU>( this );
584 zoomMenu->SetTool( commonTools );
585 aToolMenu.RegisterSubMenu( zoomMenu );
586
587 std::shared_ptr<GRID_MENU> gridMenu = std::make_shared<GRID_MENU>( this );
588 gridMenu->SetTool( commonTools );
589 aToolMenu.RegisterSubMenu( gridMenu );
590
591 aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
592 aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
593}
594
595
596void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
597{
598 SetStatusText( msg, 6 );
599}
600
601
602void EDA_DRAW_FRAME::DisplayConstraintsMsg( const wxString& msg )
603{
604 SetStatusText( msg, 7 );
605}
606
607
609{
610 wxString msg;
611
612 msg.Printf( wxS( "grid %s" ), MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x, false ) );
613
614 SetStatusText( msg, 4 );
615}
616
617
619{
620 wxString msg;
621
622 switch( GetUserUnits() )
623 {
624 case EDA_UNITS::INCHES: msg = _( "inches" ); break;
625 case EDA_UNITS::MILS: msg = _( "mils" ); break;
626 case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
627 default: msg = _( "Units" ); break;
628 }
629
630 SetStatusText( msg, 5 );
631}
632
633
634void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
635{
636 EDA_BASE_FRAME::OnSize( SizeEv );
637
638 m_frameSize = GetClientSize( );
639
640 SizeEv.Skip();
641}
642
643
645{
646 SetStatusText( GetZoomLevelIndicator(), 1 );
647
648 // Absolute and relative cursor positions are handled by overloading this function and
649 // handling the internal to user units conversion at the appropriate level.
650
651 // refresh units display
653}
654
655
657{
658 // returns a human readable value which can be displayed as zoom
659 // level indicator in dialogs.
660 double zoom = m_canvas->GetGAL()->GetZoomFactor();
661 return wxString::Format( wxT( "Z %.2f" ), zoom );
662}
663
664
666{
668
669 COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings();
670 WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
671
672 // Read units used in dialogs and toolbars
673 SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
674
676
677 m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
678
679 m_findReplaceData->findString = aCfg->m_FindReplace.find_string;
680 m_findReplaceData->replaceString = aCfg->m_FindReplace.replace_string;
681 m_findReplaceData->matchMode =
682 static_cast<EDA_SEARCH_MATCH_MODE>( aCfg->m_FindReplace.match_mode );
683 m_findReplaceData->matchCase = aCfg->m_FindReplace.match_case;
684 m_findReplaceData->searchAndReplace = aCfg->m_FindReplace.search_and_replace;
685
686 for( const wxString& s : aCfg->m_FindReplace.find_history )
688
689 for( const wxString& s : aCfg->m_FindReplace.replace_history )
691}
692
693
695{
697
698 WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
699
700 aCfg->m_System.units = static_cast<int>( GetUserUnits() );
702
704
705 aCfg->m_FindReplace.search_and_replace = m_findReplaceData->searchAndReplace;
706
707 aCfg->m_FindReplace.find_string = m_findReplaceData->findString;
708 aCfg->m_FindReplace.replace_string = m_findReplaceData->replaceString;
709
710 aCfg->m_FindReplace.find_history.clear();
711 aCfg->m_FindReplace.replace_history.clear();
712
713 for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
714 {
715 aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
716 }
717
718 for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
719 {
720 aCfg->m_FindReplace.replace_history.push_back(
721 m_replaceStringHistoryList[ i ].ToStdString() );
722 }
723
724 // Save the units used in this frame
725 if( m_toolManager )
726 {
728 {
729 aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
730 aCfg->m_System.last_metric_units = static_cast<int>( cmnTool->GetLastMetricUnits() );
731 }
732 }
733}
734
735
736void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
737 int aPadding )
738{
739 if( m_messagePanel )
740 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
741}
742
743
745{
746 if( m_messagePanel )
748}
749
750
751void EDA_DRAW_FRAME::SetMsgPanel( const std::vector<MSG_PANEL_ITEM>& aList )
752{
753 if( m_messagePanel )
754 {
756
757 for( const MSG_PANEL_ITEM& item : aList )
759 }
760}
761
762
763void EDA_DRAW_FRAME::SetMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
764 int aPadding )
765{
766 if( m_messagePanel )
767 {
769
770 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
771 }
772}
773
774
776{
777 wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
778
779 std::vector<MSG_PANEL_ITEM> items;
780 aItem->GetMsgPanelInfo( this, items );
781 SetMsgPanel( items );
782}
783
784
786{
787}
788
789
791{
792 GetCanvas()->SetEvtHandlerEnabled( true );
794}
795
796
798{
799 GetCanvas()->SwitchBackend( aCanvasType );
801
803}
804
805
807{
808#ifdef __WXMAC__
809 // Cairo renderer doesn't handle Retina displays so there's really only one game
810 // in town for Mac
812#endif
813
816
817 if( cfg )
818 canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
819
820 if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
821 || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
822 {
823 wxASSERT( false );
825 }
826
827 // Legacy canvas no longer supported. Switch to OpenGL, falls back to Cairo on failure
828 if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
830
831 return canvasType;
832}
833
834
836{
837 // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
838 // have a fixed type, or do not have a option to set the canvas type (they inherit from
839 // a parent frame)
840 FRAME_T allowed_frames[] =
841 {
846 };
847
848 bool allow_save = false;
849
850 for( unsigned ii = 0; ii < arrayDim( allowed_frames ); ii++ )
851 {
852 if( m_ident == allowed_frames[ii] )
853 {
854 allow_save = true;
855 break;
856 }
857 }
858
859 if( !allow_save )
860 return false;
861
862 if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
863 || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
864 {
865 wxASSERT( false );
866 return false;
867 }
868
870
871 if( cfg )
872 cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
873
874 return false;
875}
876
877
879{
880 const VECTOR2I& gridOrigin = GetGridOrigin();
881 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
882
883 double xOffset = fmod( gridOrigin.x, gridSize.x );
884 int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
885 double yOffset = fmod( gridOrigin.y, gridSize.y );
886 int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
887
888 return VECTOR2I( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
889}
890
891
893{
894 const VECTOR2I& gridOrigin = GetGridOrigin();
895 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
896
897 double xOffset = fmod( gridOrigin.x, gridSize.x );
898 int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
899 double yOffset = fmod( gridOrigin.y, gridSize.y );
900 int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
901
902 return VECTOR2I( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
903}
904
905
906const BOX2I EDA_DRAW_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
907{
908 return BOX2I();
909}
910
911
913{
914 // To be implemented by subclasses.
915}
916
917
918void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
919{
921}
922
923
924// Find the first child dialog.
925std::vector<wxWindow*> EDA_DRAW_FRAME::findDialogs()
926{
927 std::vector<wxWindow*> dialogs;
928
929 for( wxWindow* window : GetChildren() )
930 {
931 if( dynamic_cast<DIALOG_SHIM*>( window ) )
932 dialogs.push_back( window );
933 }
934
935 return dialogs;
936}
937
938
940{
941 bool centerView = false;
943
944 // Center if we're off the current view, or within 10% of its edge
945 r.Inflate( - (int) r.GetWidth() / 10 );
946
947 if( !r.Contains( aPos ) )
948 centerView = true;
949
950 std::vector<BOX2D> dialogScreenRects;
951
952 for( wxWindow* dialog : findDialogs() )
953 {
954 dialogScreenRects.emplace_back( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
955 dialog->GetSize() );
956 }
957
958 // Center if we're behind an obscuring dialog, or within 10% of its edge
959 for( BOX2D rect : dialogScreenRects )
960 {
961 rect.Inflate( rect.GetWidth() / 10 );
962
963 if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
964 centerView = true;
965 }
966
967 if( centerView )
968 {
969 try
970 {
971 GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
972 }
973 catch( const ClipperLib::clipperException& exc )
974 {
975 wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
976 exc.what() );
977 }
978 }
979
981}
982
983
984static const wxString productName = wxT( "KiCad E.D.A. " );
985
986
987void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
988 const wxString& aFullSheetName, const wxString& aFileName,
989 const TITLE_BLOCK& aTitleBlock,
990 const std::map<wxString, wxString>* aProperties, int aSheetCount,
991 const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
992 const wxString& aSheetLayer, bool aIsFirstPage )
993{
994 DS_DRAW_ITEM_LIST drawList;
995
996 drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
997 drawList.SetMilsToIUfactor( aMils2Iu );
998 drawList.SetPageNumber( aPageNumber );
999 drawList.SetSheetCount( aSheetCount );
1000 drawList.SetFileName( aFileName );
1001 drawList.SetSheetName( aFullSheetName );
1002 drawList.SetSheetLayer( aSheetLayer );
1003 drawList.SetProject( aProject );
1004 drawList.SetIsFirstPage( aIsFirstPage );
1005 drawList.SetProperties( aProperties );
1006
1007 drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
1008
1009 // Draw item list
1010 drawList.Print( aSettings );
1011}
1012
1013
1015 const std::map<wxString, wxString>* aProperties,
1016 double aMils2Iu, const wxString &aFilename,
1017 const wxString &aSheetLayer )
1018{
1020 return;
1021
1022 wxDC* DC = aSettings->GetPrintDC();
1023 wxPoint origin = DC->GetDeviceOrigin();
1024
1025 if( origin.y > 0 )
1026 {
1027 DC->SetDeviceOrigin( 0, 0 );
1028 DC->SetAxisOrientation( true, false );
1029 }
1030
1031 ::PrintDrawingSheet( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
1032 aProperties, aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu,
1033 &Prj(), aSheetLayer, aScreen->GetVirtualPageNumber() == 1 );
1034
1035 if( origin.y > 0 )
1036 {
1037 DC->SetDeviceOrigin( origin.x, origin.y );
1038 DC->SetAxisOrientation( true, true );
1039 }
1040}
1041
1042
1044{
1045 // Virtual function. Base class implementation returns an empty string.
1046 return wxEmptyString;
1047}
1048
1049
1050bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
1051 const wxString& wildcard, const wxString& ext,
1052 bool isDirectory, bool aIsGlobal,
1053 const wxString& aGlobalPath )
1054{
1055 wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
1056 aFilename.SetExt( ext );
1057
1058 wxString projectDir = Prj().IsNullProject() ? aFilename.GetPath() : Prj().GetProjectPath();
1059 wxString defaultDir;
1060
1061 if( aIsGlobal )
1062 {
1063 if( !GetMruPath().IsEmpty() && !GetMruPath().StartsWith( projectDir ) )
1064 defaultDir = GetMruPath();
1065 else
1066 defaultDir = aGlobalPath;
1067 }
1068 else
1069 {
1070 if( !GetMruPath().IsEmpty() && GetMruPath().StartsWith( projectDir ) )
1071 defaultDir = GetMruPath();
1072 else
1073 defaultDir = projectDir;
1074 }
1075
1076 if( isDirectory && doOpen )
1077 {
1078 wxDirDialog dlg( this, prompt, defaultDir, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
1079
1080 if( dlg.ShowModal() == wxID_CANCEL )
1081 return false;
1082
1083 aFilename = dlg.GetPath();
1084 aFilename.SetExt( ext );
1085 }
1086 else
1087 {
1088 // Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
1089 if( aFilename.GetName().empty() )
1090 aFilename.SetName( wxS( "Library" ) );
1091
1092 wxFileDialog dlg( this, prompt, defaultDir, aFilename.GetFullName(),
1093 wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
1094 : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
1095
1096 if( dlg.ShowModal() == wxID_CANCEL )
1097 return false;
1098
1099 aFilename = dlg.GetPath();
1100 aFilename.SetExt( ext );
1101 }
1102
1103 SetMruPath( aFilename.GetPath() );
1104
1105 return true;
1106}
1107
1108
1110{
1111 // Rebuild all toolbars, and update the checked state of check tools
1112 if( m_mainToolBar )
1114
1115 if( m_drawToolBar ) // Drawing tools (typically on right edge of window)
1117
1118 if( m_optionsToolBar ) // Options (typically on left edge of window)
1120
1121 if( m_auxiliaryToolBar ) // Additional tools under main toolbar
1123}
1124
1125
1127{
1129
1130 if( m_searchPane )
1131 {
1133 }
1134}
1135
1136
1138{
1139 if( !m_colorSettings || aForceRefresh )
1140 {
1141 COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings();
1142
1143 const_cast<EDA_DRAW_FRAME*>( this )->m_colorSettings = colorSettings;
1144 }
1145
1146 return m_colorSettings;
1147}
1148
1149
1151{
1153
1154 if( cmnTool )
1155 {
1156 // Tell the tool what the units used last session
1157 cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_imperial_units ) );
1158 cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_metric_units ) );
1159 }
1160
1161 // Tell the tool what units the frame is currently using
1162 switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
1163 {
1164 default:
1168 }
1169}
1170
1171
1172void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondaryUnits )
1173{
1175
1176 aPrimaryUnit = GetUserUnits();
1177 aSecondaryUnits = EDA_UNITS::MILS;
1178
1179 if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1180 {
1181 if( cmnTool )
1182 aSecondaryUnits = cmnTool->GetLastMetricUnits();
1183 else
1184 aSecondaryUnits = EDA_UNITS::MILLIMETRES;
1185 }
1186 else
1187 {
1188 if( cmnTool )
1189 aSecondaryUnits = cmnTool->GetLastImperialUnits();
1190 else
1191 aSecondaryUnits = EDA_UNITS::MILS;
1192 }
1193}
1194
1195
1197{
1199
1200 // If we had an OpenGL failure this session, use the fallback GAL but don't update the
1201 // user preference silently:
1202
1205}
1206
1207
1208void EDA_DRAW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1209{
1210 // Force a refresh of the message panel to ensure that the text is the right color
1211 // when the window activates
1212 if( !IsIconized() )
1213 m_messagePanel->Refresh();
1214}
1215
1216
1217void EDA_DRAW_FRAME::onActivate( wxActivateEvent& aEvent )
1218{
1219 handleActivateEvent( aEvent );
1220
1221 aEvent.Skip();
1222}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
BASE_SCREEN class implementation.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
static TOOL_ACTION gridProperties
Definition: actions.h:144
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION updatePreferences
Definition: actions.h:174
static TOOL_ACTION gridPreset
Definition: actions.h:142
static TOOL_ACTION updateUnits
Definition: actions.h:150
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION zoomPreset
Definition: actions.h:100
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
WINDOW_SETTINGS m_Window
Definition: app_settings.h:187
FIND_REPLACE m_FindReplace
Definition: app_settings.h:175
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
int GetPageCount() const
Definition: base_screen.h:72
int GetVirtualPageNumber() const
Definition: base_screen.h:75
const wxString & GetPageNumber() const
Definition: base_screen.cpp:71
coord_type GetWidth() const
Definition: box2.h:187
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
Color settings are a bit different than most of the settings objects in that there can be more than o...
Handles action that are shared between different applications.
Definition: common_tools.h:38
void SetLastUnits(EDA_UNITS aUnit)
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:77
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:76
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ds_draw_item.h:385
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ds_draw_item.h:427
void SetDefaultPenSize(int aPenSize)
Definition: ds_draw_item.h:444
void Print(const RENDER_SETTINGS *aSettings)
Draws the item list created by BuildDrawItemsList.
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ds_draw_item.h:432
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
Definition: ds_draw_item.h:465
void SetProperties(const std::map< wxString, wxString > *aProps)
Set properties used for text variable resolution.
Definition: ds_draw_item.h:417
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: ds_draw_item.h:442
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ds_draw_item.h:470
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:460
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:450
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:407
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
wxTimer * m_autoSaveTimer
wxAuiManager m_auimgr
int GetMaxUndoItems() const
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
wxString GetMruPath() const
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void OnSize(wxSizeEvent &aEvent)
int GetAutoSaveInterval() const
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void SetMruPath(const wxString &aPath)
The base class for create windows for drawing purpose.
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Returns bbox of document with option to not include some items.
wxArrayString m_replaceStringHistoryList
virtual void ClearMsgPanel()
Clear all messages from the message panel.
virtual void ReCreateOptToolbar()=0
EDA_DRAW_PANEL_GAL * m_canvas
This the frame's interface to setting GAL display options.
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
virtual const TITLE_BLOCK & GetTitleBlock() const =0
virtual void PrintPage(const RENDER_SETTINGS *aSettings)
Print the page pointed by current screen, set by the calling print function.
void onActivate(wxActivateEvent &aEvent)
COLOR_SETTINGS * m_colorSettings
wxChoice * m_gridSelectBox
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
void ReleaseFile()
Release the current file marked in use.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void ScriptingConsoleEnableDisable()
Toggles the scripting console visibility.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void DisplayToolMsg(const wxString &msg) override
bool IsScriptingConsoleVisible()
Gets the current visibility of the scripting console window.
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
Update the checked item in the zoom wxchoice.
virtual const PAGE_INFO & GetPageSettings() const =0
void DisplayUnitsMsg()
Display current unit pane in the status bar.
void setupUnits(APP_SETTINGS_BASE *aCfg)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
ACTION_TOOLBAR * m_optionsToolBar
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
const wxString GetZoomLevelIndicator() const
Return a human readable value for display in dialogs.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
static bool m_openGLFailureOccured
Has any failure occured when switching to OpenGL in any EDA_DRAW_FRAME?
virtual void ReCreateHToolbar()=0
std::vector< wxSocketBase * > m_sockets
interprocess communication
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
Get the pair or units in current use.
BASE_SCREEN * m_currentScreen
current used SCREEN
virtual wxString GetScreenDesc() const
VECTOR2I GetNearestGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize location to aPosition.
EDA_MSG_PANEL * m_messagePanel
virtual const VECTOR2I & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
virtual void ReCreateAuxiliaryToolbar()
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
ACTION_TOOLBAR * m_mainToolBar
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
virtual void SetGridVisibility(bool aVisible)
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
virtual void UpdateMsgPanel()
Redraw the message panel.
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const
Returns a pointer to the active color theme settings.
void ToggleUserUnits() override
void UpdateStatusBar() override
Update the status bar information.
void OnGridSettings(wxCommandEvent &event)
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
wxSocketServer * m_socketServer
ACTION_TOOLBAR * m_drawToolBar
SEARCH_PANE * m_searchPane
The current canvas type.
virtual void ReCreateVToolbar()=0
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void OnMove(wxMoveEvent &aEvent) override
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
bool IsGridVisible() const
std::vector< wxWindow * > findDialogs()
virtual void DisplayGridMsg()
Display current grid size in the status bar.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
wxArrayString m_findStringHistoryList
wxChoice * m_zoomSelectBox
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
void DisplayConstraintsMsg(const wxString &msg)
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
bool m_showBorderAndTitleBlock
VECTOR2I GetNearestHalfGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid wxchoice.
ACTION_TOOLBAR * m_auxiliaryToolBar
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
static constexpr GAL_TYPE GAL_FALLBACK
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the 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...
@ GAL_TYPE_LAST
Sentinel, do not use as a parameter.
@ GAL_TYPE_OPENGL
OpenGL implementation.
@ GAL_TYPE_NONE
GAL not used (the legacy wxDC engine is used)
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetFocus() override
virtual bool SwitchBackend(GAL_TYPE aGalType)
Switch method of rendering graphics.
void StartDrawing()
Begin drawing if it was stopped previously.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: eda_item.h:209
A panel to display various information messages.
Definition: msgpanel.h:101
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition: msgpanel.cpp:93
void EraseMsgBox()
Definition: msgpanel.cpp:197
static int GetRequiredHeight(wxWindow *aWindow)
Return the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:62
static void BuildChoiceList(wxArrayString *aGridsList, APP_SETTINGS_BASE *aCfg, EDA_DRAW_FRAME *aParent)
Definition: grid_menu.cpp:85
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
void WriteConfig(WINDOW_SETTINGS &aCfg)
void ReadCommonConfig(COMMON_SETTINGS &aCommonSettings, wxWindow *aWindow)
Read GAL config options from the common config store.
void ReadConfig(COMMON_SETTINGS &aCommonConfig, WINDOW_SETTINGS &aWindowConfig, wxWindow *aWindow)
Read application and common configs.
virtual void ResizeScreen(int aWidth, int aHeight)
Resize the canvas.
double GetZoomFactor() const
const VECTOR2D & GetGridSize() const
Return the grid size.
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
wxDC * GetPrintDC() const
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void LoadSettings()
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:511
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:641
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:577
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:617
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
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:274
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
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
Container for project specific data.
Definition: project.h:64
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:138
void OnLanguageChange()
Definition: search_pane.cpp:38
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
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:170
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:172
ACTIONS * m_actions
Definition: tools_holder.h:171
Generic, UI-independent tool event.
Definition: tool_event.h:156
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus.
Definition: tool_menu.h:43
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:50
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
void SetUserUnits(EDA_UNITS aUnits)
@ LIGHTGRAY
Definition: color4d.h:47
@ DARKGRAY
Definition: color4d.h:46
@ BLACK
Definition: color4d.h:44
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
This file is part of the common library.
#define _(s)
#define DEFAULT_MAX_UNDO_ITEMS
#define FR_HISTORY_LIST_CNT
Maximum size of the find/replace history stacks.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, const std::map< wxString, wxString > *aProperties, int aSheetCount, const wxString &aPageNumber, double aMils2Iu, const PROJECT *aProject, const wxString &aSheetLayer, bool aIsFirstPage)
Print the border and title block.
static const wxString productName
EDA_SEARCH_MATCH_MODE
EDA_UNITS
Definition: eda_units.h:43
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_PL_EDITOR
Definition: frame_type.h:55
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
@ FRAME_GERBER
Definition: frame_type.h:53
@ FRAME_PYTHON
Definition: frame_type.h:51
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
File locking utilities.
This file contains miscellaneous commonly used macros and functions.
Message panel definition file.
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:29
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: ui_common.cpp:70
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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
std::vector< FAB_LAYER_COLOR > dummy
std::vector< wxString > replace_history
Definition: app_settings.h:117
std::vector< wxString > find_history
Definition: app_settings.h:115
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:92
GRID_SETTINGS grid
Definition: app_settings.h:99
std::vector< double > zoom_factors
Definition: app_settings.h:96
wxLogTrace helper definitions.
Functions to provide common constants and other functions to assist in making a consistent UI.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618