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