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