KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 <core/kicad_algo.h>
31#include <dialog_shim.h>
32#include <eda_draw_frame.h>
33#include <file_history.h>
34#include <id.h>
35#include <kiface_base.h>
36#include <lockfile.h>
37#include <macros.h>
38#include <math/vector2wx.h>
39#include <page_info.h>
40#include <paths.h>
41#include <pgm_base.h>
42#include <render_settings.h>
47#include <title_block.h>
48#include <tool/actions.h>
49#include <tool/common_tools.h>
50#include <tool/grid_menu.h>
53#include <tool/tool_manager.h>
54#include <tool/tool_menu.h>
55#include <tool/zoom_menu.h>
56#include <trace_helpers.h>
57#include <view/view.h>
59#include <widgets/msgpanel.h>
60#include <wx/event.h>
61#include <wx/snglinst.h>
63#include <widgets/ui_common.h>
64#include <widgets/search_pane.h>
65#include <wx/dirdlg.h>
66#include <wx/filedlg.h>
67#include <wx/msgdlg.h>
68#include <wx/socket.h>
69
70#include <wx/snglinst.h>
71#include <wx/fdrepdlg.h>
72
73#define FR_HISTORY_LIST_CNT 10
74
75
76BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
79
80 EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate )
81END_EVENT_TABLE()
82
83
84bool EDA_DRAW_FRAME::m_openGLFailureOccured = false;
85
86
87EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
88 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
89 long aStyle, const wxString& aFrameName,
90 const EDA_IU_SCALE& aIuScale ) :
91 KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, aIuScale ),
92 m_socketServer( nullptr )
93{
94 m_mainToolBar = nullptr;
95 m_drawToolBar = nullptr;
96 m_optionsToolBar = nullptr;
97 m_auxiliaryToolBar = nullptr;
98 m_gridSelectBox = nullptr;
99 m_zoomSelectBox = nullptr;
100 m_searchPane = nullptr;
101 m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
102
104 m_canvas = nullptr;
105 m_toolDispatcher = nullptr;
106 m_messagePanel = nullptr;
107 m_currentScreen = nullptr;
108 m_showBorderAndTitleBlock = false; // true to display reference sheet.
109 m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
110 m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
111 // BLACK for Pcbnew, BLACK or WHITE for Eeschema
112 m_colorSettings = nullptr;
113 m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
114 m_polarCoords = false;
115 m_findReplaceData = std::make_unique<EDA_SEARCH_DATA>();
116
117 SetUserUnits( EDA_UNITS::MILLIMETRES );
118
119 m_auimgr.SetFlags( wxAUI_MGR_DEFAULT );
120
121 CreateStatusBar( 8 )->SetDoubleBuffered( true );
122
123 // set the size of the status bar subwindows:
124
125 wxWindow* stsbar = GetStatusBar();
126 int spacer = KIUI::GetTextSize( wxT( "M" ), stsbar ).x * 2;
127
128 int dims[] = {
129
130 // remainder of status bar on far left is set to a default or whatever is left over.
131 -1,
132
133 // When using GetTextSize() remember the width of character '1' is not the same
134 // as the width of '0' unless the font is fixed width, and it usually won't be.
135
136 // zoom:
137 KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + spacer,
138
139 // cursor coords
140 KIUI::GetTextSize( wxT( "X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer,
141
142 // delta distances
143 KIUI::GetTextSize( wxT( "dx 1234.1234 dy 1234.1234 dist 1234.1234" ), stsbar ).x + spacer,
144
145 // grid size
146 KIUI::GetTextSize( wxT( "grid X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer,
147
148 // units display, Inches is bigger than mm
149 KIUI::GetTextSize( _( "Inches" ), stsbar ).x + spacer,
150
151 // Size for the "Current Tool" panel; longest string from SetTool()
152 KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + spacer,
153
154 // constraint mode
155 KIUI::GetTextSize( _( "Constrain to H, V, 45" ), stsbar ).x + spacer
156 };
157
158 SetStatusWidths( arrayDim( dims ), dims );
159 stsbar->SetFont( KIUI::GetStatusFont( this ) );
160
161 // Create child subwindows.
162 GetClientSize( &m_frameSize.x, &m_frameSize.y );
163 m_framePos.x = m_framePos.y = 0;
164 m_frameSize.y -= m_msgFrameHeight;
165
166 m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ),
167 wxSize( m_frameSize.x, m_msgFrameHeight ) );
168
169 m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
170
171#if wxCHECK_VERSION( 3, 1, 3 )
172 Bind( wxEVT_DPI_CHANGED,
173 [&]( wxDPIChangedEvent& )
174 {
175 wxMoveEvent dummy;
176 OnMove( dummy );
177
178 // we need to kludge the msg panel to the correct size again
179 // especially important even for first launches as the constructor of the window
180 // here usually doesn't have the correct dpi awareness yet
181 m_frameSize.y += m_msgFrameHeight;
182 m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
183 m_frameSize.y -= m_msgFrameHeight;
184
185 m_messagePanel->SetPosition( wxPoint( 0, m_frameSize.y ) );
186 m_messagePanel->SetSize( m_frameSize.x, m_msgFrameHeight );
187 } );
188#endif
189}
190
191
193{
195
196 delete m_actions;
197 delete m_toolManager;
198 delete m_toolDispatcher;
199 delete m_canvas;
200
201 delete m_currentScreen;
202 m_currentScreen = nullptr;
203
204 m_auimgr.UnInit();
205
206 ReleaseFile();
207}
208
209
211{
212 if( m_file_checker.get() != nullptr )
213 m_file_checker->UnlockFile();
214}
215
216
217bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
218{
219 // We need to explicitly reset here to get the deletion before
220 // we create a new unique_ptr that may be for the same file
221 m_file_checker.reset();
222
223 m_file_checker = std::make_unique<LOCKFILE>( aFileName );
224
225 return m_file_checker->Locked();
226}
227
228
230{
231 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
232
233 wxRect rect = GetScreenRect();
234 wxPoint center = rect.GetPosition() + rect.GetSize() / 2;
235
236 if( !frame )
237 {
238 frame = Kiway().Player( FRAME_PYTHON, true, Kiway().GetTop() );
239
240 // If we received an error in the CTOR due to Python-ness, don't crash
241 if( !frame )
242 return;
243
244 if( !frame->IsVisible() )
245 frame->Show( true );
246
247 // On Windows, Raise() does not bring the window on screen, when iconized
248 if( frame->IsIconized() )
249 frame->Iconize( false );
250
251 frame->Raise();
252 frame->SetPosition( center - frame->GetSize() / 2 );
253
254 return;
255 }
256
257 frame->Show( !frame->IsVisible() );
258 frame->SetPosition( center - frame->GetSize() / 2 );
259}
260
261
263{
264 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
265 return frame && frame->IsVisible();
266}
267
268
270{
271 // Notify all tools the units have changed
272 if( m_toolManager )
274
277}
278
279
281{
283 {
285 m_toolManager->GetTool<COMMON_TOOLS>()->ToggleUnits( dummy );
286 }
287 else
288 {
289 SetUserUnits( GetUserUnits() == EDA_UNITS::INCHES ? EDA_UNITS::MILLIMETRES
290 : EDA_UNITS::INCHES );
292
293 wxCommandEvent e( EDA_EVT_UNITS_CHANGED );
294 ProcessEventLocally( e );
295 }
296}
297
298
299void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
300{
301 EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
302
303 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
305
306 if( m_supportsAutoSave && m_autoSaveTimer->IsRunning() )
307 {
308 if( GetAutoSaveInterval() > 0 )
309 {
310 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
311 }
312 else
313 {
314 m_autoSaveTimer->Stop();
315 m_autoSavePending = false;
316 }
317 }
318
319 viewControls->LoadSettings();
320
321 m_galDisplayOptions.ReadCommonConfig( *settings, this );
322
323#ifndef __WXMAC__
325
326 if( m_canvasType != GetCanvas()->GetBackend() )
327 {
328 // Try to switch (will automatically fallback if necessary)
331 bool success = newGAL == m_canvasType;
332
333 if( !success )
334 {
335 m_canvasType = newGAL;
336 m_openGLFailureOccured = true; // Store failure for other EDA_DRAW_FRAMEs
337 }
338 }
339#endif
340
341 // Notify all tools the preferences have changed
342 if( m_toolManager )
344}
345
346
348{
349 if( m_messagePanel )
351}
352
353
355{
358
359 if( m_gridSelectBox == nullptr )
360 return;
361
362 // Update grid values with the current units setting.
363 m_gridSelectBox->Clear();
364 wxArrayString gridsList;
365
366 wxCHECK( config(), /* void */ );
367
368 GRID_MENU::BuildChoiceList( &gridsList, config(), this );
369
370 for( const wxString& grid : gridsList )
371 m_gridSelectBox->Append( grid );
372
373 m_gridSelectBox->Append( wxT( "---" ) );
374 m_gridSelectBox->Append( _( "Edit User Grid..." ) );
375
376 m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx );
377}
378
379
380void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
381{
382 // No need to update the grid select box if it doesn't exist or the grid setting change
383 // was made using the select box.
384 if( m_gridSelectBox == nullptr )
385 return;
386
387 wxCHECK( config(), /* void */ );
388
389 int idx = config()->m_Window.grid.last_size_idx;
390 idx = std::max( 0, std::min( idx, (int) m_gridSelectBox->GetCount() - 1 ) );
391
392 if( idx != m_gridSelectBox->GetSelection() )
393 m_gridSelectBox->SetSelection( idx );
394}
395
396
397
398void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
399{
400 // No need to update the grid select box if it doesn't exist or the grid setting change
401 // was made using the select box.
402 if( m_zoomSelectBox == nullptr )
403 return;
404
405 double zoom = GetCanvas()->GetGAL()->GetZoomFactor();
406
407 wxCHECK( config(), /* void */ );
408
409 const std::vector<double>& zoomList = config()->m_Window.zoom_factors;
410 int curr_selection = m_zoomSelectBox->GetSelection();
411 int new_selection = 0; // select zoom auto
412 double last_approx = 1e9; // large value to start calculation
413
414 // Search for the nearest available value to the current zoom setting, and select it
415 for( size_t jj = 0; jj < zoomList.size(); ++jj )
416 {
417 double rel_error = std::fabs( zoomList[jj] - zoom ) / zoom;
418
419 if( rel_error < last_approx )
420 {
421 last_approx = rel_error;
422 // zoom IDs in m_zoomSelectBox start with 1 (leaving 0 for auto-zoom choice)
423 new_selection = jj+1;
424 }
425 }
426
427 if( curr_selection != new_selection )
428 m_zoomSelectBox->SetSelection( new_selection );
429}
430
432{
433 DisplayErrorMessage( this, wxT("EDA_DRAW_FRAME::PrintPage() error") );
434}
435
436
437void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
438{
439 wxCHECK_RET( m_gridSelectBox, wxS( "m_gridSelectBox uninitialized" ) );
440
441 int idx = m_gridSelectBox->GetCurrentSelection();
442
443 if( idx == int( m_gridSelectBox->GetCount() ) - 2 )
444 {
445 // wxWidgets will check the separator, which we don't want.
446 // Re-check the current grid.
447 wxUpdateUIEvent dummy;
449 }
450 else if( idx == int( m_gridSelectBox->GetCount() ) - 1 )
451 {
452 // wxWidgets will check the Grid Settings... entry, which we don't want.
453 // Re-check the current grid.
454 wxUpdateUIEvent dummy;
456
457 // Give a time-slice to close the menu before opening the dialog.
458 // (Only matters on some versions of GTK.)
459 wxSafeYield();
460
462 }
463 else
464 {
465 m_toolManager->RunAction( ACTIONS::gridPreset, true, static_cast<intptr_t>( idx ) );
466 }
467
469 m_canvas->Refresh();
470 // Needed on Windows because clicking on m_gridSelectBox remove the focus from m_canvas
471 // (Windows specific
473}
474
475
476void EDA_DRAW_FRAME::OnGridSettings( wxCommandEvent& aEvent )
477{
478 DIALOG_GRID_SETTINGS dlg( this );
479
480 if( dlg.ShowModal() == wxID_OK )
481 {
483 GetCanvas()->Refresh();
484 }
485}
486
487
489{
490 wxCHECK( config(), true );
491
492 return config()->m_Window.grid.show;
493}
494
495
497{
498 wxCHECK( config(), /* void */ );
499
500 config()->m_Window.grid.show = aVisible;
501
502 // Update the display with the new grid
503 if( GetCanvas() )
504 {
505 // Check to ensure these exist, since this function could be called before
506 // the GAL and View have been created
507 if( GetCanvas()->GetGAL() )
508 GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
509
510 if( GetCanvas()->GetView() )
512
513 GetCanvas()->Refresh();
514 }
515}
516
517
519{
520 if( m_zoomSelectBox == nullptr )
521 return;
522
523 double zoom = m_canvas->GetGAL()->GetZoomFactor();
524
525 m_zoomSelectBox->Clear();
526 m_zoomSelectBox->Append( _( "Zoom Auto" ) );
527 m_zoomSelectBox->SetSelection( 0 );
528
529 wxCHECK( config(), /* void */ );
530
531 for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i )
532 {
533 double current = config()->m_Window.zoom_factors[i];
534
535 m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) );
536
537 if( zoom == current )
538 m_zoomSelectBox->SetSelection( i + 1 );
539 }
540}
541
542
543void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
544{
545 wxCHECK_RET( m_zoomSelectBox, wxS( "m_zoomSelectBox uninitialized" ) );
546
547 int id = m_zoomSelectBox->GetCurrentSelection();
548
549 if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
550 return;
551
552 m_toolManager->RunAction( ACTIONS::zoomPreset, true, static_cast<intptr_t>( id ) );
554 m_canvas->Refresh();
555 // Needed on Windows because clicking on m_zoomSelectBox remove the focus from m_canvas
556 // (Windows specific
558}
559
560
561void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
562{
563 // If the window is moved to a different display, the scaling factor may change
564 double oldFactor = m_galDisplayOptions.m_scaleFactor;
566
567 if( oldFactor != m_galDisplayOptions.m_scaleFactor && m_canvas )
568 {
569 wxSize clientSize = GetClientSize();
570 GetCanvas()->GetGAL()->ResizeScreen( clientSize.x, clientSize.y );
572 }
573
574 aEvent.Skip();
575}
576
577
579{
581 CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
582
583 aMenu.AddSeparator( 1000 );
584
585 std::shared_ptr<ZOOM_MENU> zoomMenu = std::make_shared<ZOOM_MENU>( this );
586 zoomMenu->SetTool( commonTools );
587 aToolMenu.RegisterSubMenu( zoomMenu );
588
589 std::shared_ptr<GRID_MENU> gridMenu = std::make_shared<GRID_MENU>( this );
590 gridMenu->SetTool( commonTools );
591 aToolMenu.RegisterSubMenu( gridMenu );
592
593 aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
594 aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
595}
596
597
598void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
599{
600 SetStatusText( msg, 6 );
601}
602
603
604void EDA_DRAW_FRAME::DisplayConstraintsMsg( const wxString& msg )
605{
606 SetStatusText( msg, 7 );
607}
608
609
611{
612 wxString msg;
613
614 msg.Printf( _( "grid %s" ), MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x,
615 false ) );
616
617 SetStatusText( msg, 4 );
618}
619
620
622{
623 wxString msg;
624
625 switch( GetUserUnits() )
626 {
627 case EDA_UNITS::INCHES: msg = _( "inches" ); break;
628 case EDA_UNITS::MILS: msg = _( "mils" ); break;
629 case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
630 default: msg = _( "Units" ); break;
631 }
632
633 SetStatusText( msg, 5 );
634}
635
636
637void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
638{
639 EDA_BASE_FRAME::OnSize( SizeEv );
640
641 m_frameSize = GetClientSize( );
642
643 SizeEv.Skip();
644}
645
646
648{
649 SetStatusText( GetZoomLevelIndicator(), 1 );
650
651 // Absolute and relative cursor positions are handled by overloading this function and
652 // handling the internal to user units conversion at the appropriate level.
653
654 // refresh units display
656}
657
658
660{
661 // returns a human readable value which can be displayed as zoom
662 // level indicator in dialogs.
663 double zoom = m_canvas->GetGAL()->GetZoomFactor();
664 return wxString::Format( wxT( "Z %.2f" ), zoom );
665}
666
667
669{
671
672 COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings();
673 WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
674
675 // Read units used in dialogs and toolbars
676 SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
677
679
680 m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
681
682 m_findReplaceData->findString = aCfg->m_FindReplace.find_string;
683 m_findReplaceData->replaceString = aCfg->m_FindReplace.replace_string;
684 m_findReplaceData->matchMode =
685 static_cast<EDA_SEARCH_MATCH_MODE>( aCfg->m_FindReplace.match_mode );
686 m_findReplaceData->matchCase = aCfg->m_FindReplace.match_case;
687 m_findReplaceData->searchAndReplace = aCfg->m_FindReplace.search_and_replace;
688
689 for( const wxString& s : aCfg->m_FindReplace.find_history )
691
692 for( const wxString& s : aCfg->m_FindReplace.replace_history )
694}
695
696
698{
700
701 WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
702
703 aCfg->m_System.units = static_cast<int>( GetUserUnits() );
705
707
708 aCfg->m_FindReplace.search_and_replace = m_findReplaceData->searchAndReplace;
709
710 aCfg->m_FindReplace.find_string = m_findReplaceData->findString;
711 aCfg->m_FindReplace.replace_string = m_findReplaceData->replaceString;
712
713 aCfg->m_FindReplace.find_history.clear();
714 aCfg->m_FindReplace.replace_history.clear();
715
716 for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
717 {
718 aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
719 }
720
721 for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
722 {
723 aCfg->m_FindReplace.replace_history.push_back(
724 m_replaceStringHistoryList[ i ].ToStdString() );
725 }
726
727 // Save the units used in this frame
728 if( m_toolManager )
729 {
731 {
732 aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
733 aCfg->m_System.last_metric_units = static_cast<int>( cmnTool->GetLastMetricUnits() );
734 }
735 }
736}
737
738
739void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
740 int aPadding )
741{
743 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
744}
745
746
748{
751}
752
753
754void EDA_DRAW_FRAME::SetMsgPanel( const std::vector<MSG_PANEL_ITEM>& aList )
755{
757 {
759
760 for( const MSG_PANEL_ITEM& item : aList )
762 }
763}
764
765
766void EDA_DRAW_FRAME::SetMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
767 int aPadding )
768{
770 {
772 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
773 }
774}
775
776
778{
779 wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
780
781 std::vector<MSG_PANEL_ITEM> items;
782 aItem->GetMsgPanelInfo( this, items );
783 SetMsgPanel( items );
784}
785
786
788{
789}
790
791
793{
794 GetCanvas()->SetEvtHandlerEnabled( true );
796}
797
798
800{
801 GetCanvas()->SwitchBackend( aCanvasType );
803
805}
806
807
809{
810#ifdef __WXMAC__
811 // Cairo renderer doesn't handle Retina displays so there's really only one game
812 // in town for Mac
814#endif
815
818
819 if( cfg )
820 canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
821
822 if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
823 || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
824 {
825 wxASSERT( false );
827 }
828
829 // Legacy canvas no longer supported. Switch to OpenGL, falls back to Cairo on failure
830 if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
832
833 return canvasType;
834}
835
836
838{
839 // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
840 // have a fixed type, or do not have a option to set the canvas type (they inherit from
841 // a parent frame)
842 static std::vector<FRAME_T> s_allowedFrames =
843 {
848 };
849
850 if( !alg::contains( s_allowedFrames, m_ident ) )
851 return false;
852
853 if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
854 || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
855 {
856 wxASSERT( false );
857 return false;
858 }
859
860 if( APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings() )
861 cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
862
863 return false;
864}
865
866
868{
869 const VECTOR2I& gridOrigin = GetGridOrigin();
870 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
871
872 double xOffset = fmod( gridOrigin.x, gridSize.x );
873 int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
874 double yOffset = fmod( gridOrigin.y, gridSize.y );
875 int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
876
877 return VECTOR2I( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
878}
879
880
882{
883 const VECTOR2I& gridOrigin = GetGridOrigin();
884 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
885
886 double xOffset = fmod( gridOrigin.x, gridSize.x );
887 int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
888 double yOffset = fmod( gridOrigin.y, gridSize.y );
889 int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
890
891 return VECTOR2I( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
892}
893
894
895const BOX2I EDA_DRAW_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
896{
897 return BOX2I();
898}
899
900
902{
903 // To be implemented by subclasses.
904}
905
906
907void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
908{
910}
911
912
913// Find the first child dialog.
914std::vector<wxWindow*> EDA_DRAW_FRAME::findDialogs()
915{
916 std::vector<wxWindow*> dialogs;
917
918 for( wxWindow* window : GetChildren() )
919 {
920 if( dynamic_cast<DIALOG_SHIM*>( window ) )
921 dialogs.push_back( window );
922 }
923
924 return dialogs;
925}
926
927
929{
930 bool centerView = false;
932
933 // Center if we're off the current view, or within 10% of its edge
934 r.Inflate( - (int) r.GetWidth() / 10 );
935
936 if( !r.Contains( aPos ) )
937 centerView = true;
938
939 std::vector<BOX2D> dialogScreenRects;
940
941 for( wxWindow* dialog : findDialogs() )
942 {
943 dialogScreenRects.emplace_back( ToVECTOR2D( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ) ),
944 ToVECTOR2D( dialog->GetSize() ) );
945 }
946
947 // Center if we're behind an obscuring dialog, or within 10% of its edge
948 for( BOX2D rect : dialogScreenRects )
949 {
950 rect.Inflate( rect.GetWidth() / 10 );
951
952 if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
953 centerView = true;
954 }
955
956 if( centerView )
957 {
958 try
959 {
960 GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
961 }
962 catch( const ClipperLib::clipperException& exc )
963 {
964 wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
965 exc.what() );
966 }
967 }
968
970}
971
972
973static const wxString productName = wxT( "KiCad E.D.A. " );
974
975
976void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
977 const wxString& aSheetName, const wxString& aSheetPath,
978 const wxString& aFileName, const TITLE_BLOCK& aTitleBlock,
979 const std::map<wxString, wxString>* aProperties, int aSheetCount,
980 const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
981 const wxString& aSheetLayer, bool aIsFirstPage )
982{
983 DS_DRAW_ITEM_LIST drawList;
984
985 drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
986 drawList.SetMilsToIUfactor( aMils2Iu );
987 drawList.SetPageNumber( aPageNumber );
988 drawList.SetSheetCount( aSheetCount );
989 drawList.SetFileName( aFileName );
990 drawList.SetSheetName( aSheetName );
991 drawList.SetSheetPath( aSheetPath );
992 drawList.SetSheetLayer( aSheetLayer );
993 drawList.SetProject( aProject );
994 drawList.SetIsFirstPage( aIsFirstPage );
995 drawList.SetProperties( aProperties );
996
997 drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
998
999 // Draw item list
1000 drawList.Print( aSettings );
1001}
1002
1003
1005 const std::map<wxString, wxString>* aProperties,
1006 double aMils2Iu, const wxString &aFilename,
1007 const wxString &aSheetLayer )
1008{
1010 return;
1011
1012 wxDC* DC = aSettings->GetPrintDC();
1013 wxPoint origin = DC->GetDeviceOrigin();
1014
1015 if( origin.y > 0 )
1016 {
1017 DC->SetDeviceOrigin( 0, 0 );
1018 DC->SetAxisOrientation( true, false );
1019 }
1020
1022 aFilename, GetTitleBlock(), aProperties, aScreen->GetPageCount(),
1023 aScreen->GetPageNumber(), aMils2Iu, &Prj(), aSheetLayer,
1024 aScreen->GetVirtualPageNumber() == 1 );
1025
1026 if( origin.y > 0 )
1027 {
1028 DC->SetDeviceOrigin( origin.x, origin.y );
1029 DC->SetAxisOrientation( true, true );
1030 }
1031}
1032
1033
1035{
1036 // Virtual function. Base class implementation returns an empty string.
1037 return wxEmptyString;
1038}
1039
1040
1042{
1043 // Virtual function. Base class implementation returns an empty string.
1044 return wxEmptyString;
1045}
1046
1047
1048bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
1049 const wxString& wildcard, const wxString& ext,
1050 bool isDirectory, bool aIsGlobal,
1051 const wxString& aGlobalPath )
1052{
1053 wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
1054 aFilename.SetExt( ext );
1055
1056 wxString projectDir = Prj().IsNullProject() ? aFilename.GetPath() : Prj().GetProjectPath();
1057 wxString defaultDir;
1058
1059 if( aIsGlobal )
1060 {
1061 if( !GetMruPath().IsEmpty() && !GetMruPath().StartsWith( projectDir ) )
1062 defaultDir = GetMruPath();
1063 else
1064 defaultDir = aGlobalPath;
1065 }
1066 else
1067 {
1068 if( !GetMruPath().IsEmpty() && GetMruPath().StartsWith( projectDir ) )
1069 defaultDir = GetMruPath();
1070 else
1071 defaultDir = projectDir;
1072 }
1073
1074 if( isDirectory && doOpen )
1075 {
1076 wxDirDialog dlg( this, prompt, defaultDir, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
1077
1078 if( dlg.ShowModal() == wxID_CANCEL )
1079 return false;
1080
1081 aFilename = dlg.GetPath();
1082 aFilename.SetExt( ext );
1083 }
1084 else
1085 {
1086 // Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
1087 if( aFilename.GetName().empty() )
1088 aFilename.SetName( wxS( "Library" ) );
1089
1090 wxFileDialog dlg( this, prompt, defaultDir, aFilename.GetFullName(),
1091 wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
1092 : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
1093
1094 if( dlg.ShowModal() == wxID_CANCEL )
1095 return false;
1096
1097 aFilename = dlg.GetPath();
1098 aFilename.SetExt( ext );
1099 }
1100
1101 SetMruPath( aFilename.GetPath() );
1102
1103 return true;
1104}
1105
1106
1108{
1109 // Rebuild all toolbars, and update the checked state of check tools
1110 if( m_mainToolBar )
1112
1113 if( m_drawToolBar ) // Drawing tools (typically on right edge of window)
1115
1116 if( m_optionsToolBar ) // Options (typically on left edge of window)
1118
1119 if( m_auxiliaryToolBar ) // Additional tools under main toolbar
1121}
1122
1123
1125{
1127
1128 if( m_searchPane )
1129 {
1131 }
1132}
1133
1134
1136{
1137 if( !m_colorSettings || aForceRefresh )
1138 {
1139 COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings();
1140
1141 const_cast<EDA_DRAW_FRAME*>( this )->m_colorSettings = colorSettings;
1142 }
1143
1144 return m_colorSettings;
1145}
1146
1147
1149{
1151
1152 if( cmnTool )
1153 {
1154 // Tell the tool what the units used last session
1155 cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_imperial_units ) );
1156 cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_metric_units ) );
1157 }
1158
1159 // Tell the tool what units the frame is currently using
1160 switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
1161 {
1162 default:
1163 case EDA_UNITS::MILLIMETRES: m_toolManager->RunAction( ACTIONS::millimetersUnits ); break;
1164 case EDA_UNITS::INCHES: m_toolManager->RunAction( ACTIONS::inchesUnits ); break;
1165 case EDA_UNITS::MILS: m_toolManager->RunAction( ACTIONS::milsUnits ); break;
1166 }
1167}
1168
1169
1170void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondaryUnits )
1171{
1173
1174 aPrimaryUnit = GetUserUnits();
1175 aSecondaryUnits = EDA_UNITS::MILS;
1176
1177 if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1178 {
1179 if( cmnTool )
1180 aSecondaryUnits = cmnTool->GetLastMetricUnits();
1181 else
1182 aSecondaryUnits = EDA_UNITS::MILLIMETRES;
1183 }
1184 else
1185 {
1186 if( cmnTool )
1187 aSecondaryUnits = cmnTool->GetLastImperialUnits();
1188 else
1189 aSecondaryUnits = EDA_UNITS::MILS;
1190 }
1191}
1192
1193
1195{
1197
1198 // If we had an OpenGL failure this session, use the fallback GAL but don't update the
1199 // user preference silently:
1200
1203}
1204
1205
1206void EDA_DRAW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1207{
1208 // Force a refresh of the message panel to ensure that the text is the right color
1209 // when the window activates
1210 if( !IsIconized() )
1211 m_messagePanel->Refresh();
1212}
1213
1214
1215void EDA_DRAW_FRAME::onActivate( wxActivateEvent& aEvent )
1216{
1217 handleActivateEvent( aEvent );
1218
1219 aEvent.Skip();
1220}
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:145
static TOOL_ACTION millimetersUnits
Definition: actions.h:150
static TOOL_ACTION updatePreferences
Definition: actions.h:175
static TOOL_ACTION gridPreset
Definition: actions.h:143
static TOOL_ACTION updateUnits
Definition: actions.h:151
static TOOL_ACTION milsUnits
Definition: actions.h:149
static TOOL_ACTION inchesUnits
Definition: actions.h:148
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION zoomPreset
Definition: actions.h:101
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:395
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetSheetPath(const wxString &aSheetPath)
Set the sheet path to draw/plot.
Definition: ds_draw_item.h:447
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ds_draw_item.h:437
void SetDefaultPenSize(int aPenSize)
Definition: ds_draw_item.h:454
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:442
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
Definition: ds_draw_item.h:475
void SetProperties(const std::map< wxString, wxString > *aProps)
Set properties used for text variable resolution.
Definition: ds_draw_item.h:427
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: ds_draw_item.h:452
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ds_draw_item.h:480
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:470
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:460
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:417
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)
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
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.
virtual wxString GetFullScreenDesc() const
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void DisplayToolMsg(const wxString &msg) override
std::unique_ptr< LOCKFILE > m_file_checker
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
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.
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.
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
@ 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:192
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:95
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
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:508
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:574
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:279
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:432
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:37
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:46
@ DARKGRAY
Definition: color4d.h:45
@ BLACK
Definition: color4d.h:43
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:308
This file is part of the common library.
#define _(s)
#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 &aSheetName, const wxString &aSheetPath, 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
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
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:588
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)
Definition: vector2wx.h:40