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 <stambaughw@gmail.com>
6  * Copyright (C) 2004-2020 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_i.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>
41 #include <settings/app_settings.h>
45 #include <title_block.h>
46 #include <tool/actions.h>
47 #include <tool/common_tools.h>
48 #include <tool/grid_menu.h>
50 #include <tool/tool_dispatcher.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/snglinst.h>
60 #include <widgets/ui_common.h>
61 
62 #define FR_HISTORY_LIST_CNT 10
63 
64 
65 BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
68 END_EVENT_TABLE()
69 
70 
71 EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
72  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
73  long aStyle, const wxString & aFrameName ) :
74  KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
75 {
76  m_socketServer = nullptr;
77  m_mainToolBar = NULL;
78  m_drawToolBar = NULL;
79  m_optionsToolBar = NULL;
80  m_auxiliaryToolBar = NULL;
81  m_gridSelectBox = NULL;
82  m_zoomSelectBox = NULL;
83  m_firstRunDialogSetting = 0;
84  m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
85 
86  m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
87  m_canvas = NULL;
88  m_toolDispatcher = NULL;
89  m_messagePanel = NULL;
90  m_currentScreen = NULL;
91  m_showBorderAndTitleBlock = false; // true to display reference sheet.
92  m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
93  m_showPageLimits = false;
94  m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
95  // BLACK for Pcbnew, BLACK or WHITE for Eeschema
96  m_colorSettings = nullptr;
97  m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
98  m_userUnits = EDA_UNITS::MILLIMETRES;
99  m_polarCoords = false;
100  m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
101 
102  m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
103 
104  CreateStatusBar( 7 );
105 
106  // set the size of the status bar subwindows:
107 
108  wxWindow* stsbar = GetStatusBar();
109 
110  int dims[] = {
111 
112  // remainder of status bar on far left is set to a default or whatever is left over.
113  -1,
114 
115  // When using GetTextSize() remember the width of character '1' is not the same
116  // as the width of '0' unless the font is fixed width, and it usually won't be.
117 
118  // zoom:
119  KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
120 
121  // cursor coords
122  KIUI::GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
123 
124  // delta distances
125  KIUI::GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
126 
127  // grid size
128  KIUI::GetTextSize( wxT( "grid X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
129 
130  // units display, Inches is bigger than mm
131  KIUI::GetTextSize( _( "Inches" ), stsbar ).x + 10,
132 
133  // Size for the "Current Tool" panel; longest string from SetTool()
134  KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
135  };
136 
137  SetStatusWidths( arrayDim( dims ), dims );
138 
139  // Create child subwindows.
140  GetClientSize( &m_frameSize.x, &m_frameSize.y );
141  m_framePos.x = m_framePos.y = 0;
142  m_frameSize.y -= m_msgFrameHeight;
143 
144  m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ),
145  wxSize( m_frameSize.x, m_msgFrameHeight ) );
146 
147  m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
148 }
149 
150 
152 {
153  delete m_socketServer;
154 
155  for( auto socket : m_sockets )
156  {
157  socket->Shutdown();
158  socket->Destroy();
159  }
160 
162 
163  delete m_actions;
164  delete m_toolManager;
165  delete m_toolDispatcher;
166  delete m_canvas;
167 
168  delete m_currentScreen;
170 
171  delete m_findReplaceData;
172 
173  m_auimgr.UnInit();
174 
175  ReleaseFile();
176 }
177 
178 
180 {
181  m_file_checker = nullptr;
182 }
183 
184 
185 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
186 {
187  m_file_checker = ::LockFile( aFileName );
188 
189  return bool( m_file_checker );
190 }
191 
192 
194 {
195  // Notify all tools the units have changed
196  if( m_toolManager )
198 
199  UpdateStatusBar();
200  UpdateMsgPanel();
201 }
202 
203 
205 {
208 
209  wxCommandEvent e( UNITS_CHANGED );
210  ProcessEventLocally( e );
211 }
212 
213 
214 void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
215 {
216  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
217 
218  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
219  KIGFX::VIEW_CONTROLS* viewControls = GetCanvas()->GetViewControls();
220 
222 
223  viewControls->LoadSettings();
224 
225  m_galDisplayOptions.ReadCommonConfig( *settings, this );
226 }
227 
228 
230 {
231  if( m_messagePanel )
233 }
234 
235 
237 {
238  UpdateStatusBar();
239  DisplayUnitsMsg();
240 
241  if( m_gridSelectBox == NULL )
242  return;
243 
244  // Update grid values with the current units setting.
245  m_gridSelectBox->Clear();
246  wxArrayString gridsList;
247 
248  GRID_MENU::BuildChoiceList( &gridsList, config(), this );
249 
250  for( const wxString& grid : gridsList )
251  m_gridSelectBox->Append( grid );
252 
253  m_gridSelectBox->Append( wxT( "---" ) );
254  m_gridSelectBox->Append( _( "Edit User Grid..." ) );
255 
256  m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx );
257 }
258 
259 
260 void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
261 {
262  // No need to update the grid select box if it doesn't exist or the grid setting change
263  // was made using the select box.
264  if( m_gridSelectBox == NULL )
265  return;
266 
267  int idx = config()->m_Window.grid.last_size_idx;
268  idx = std::max( 0, std::min( idx, (int) m_gridSelectBox->GetCount() - 1 ) );
269 
270  if( idx != m_gridSelectBox->GetSelection() )
271  m_gridSelectBox->SetSelection( idx );
272 }
273 
274 
276 {
277  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
278 }
279 
280 
281 /*
282  * Respond to selections in the toolbar grid popup
283  */
284 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
285 {
286  wxCHECK_RET( m_gridSelectBox, "m_gridSelectBox uninitialized" );
287 
288  int idx = m_gridSelectBox->GetCurrentSelection();
289 
290  if( idx == int( m_gridSelectBox->GetCount() ) - 2 )
291  {
292  // wxWidgets will check the separator, which we don't want.
293  // Re-check the current grid.
294  wxUpdateUIEvent dummy;
296  }
297  else if( idx == int( m_gridSelectBox->GetCount() ) - 1 )
298  {
299  // wxWidgets will check the Grid Settings... entry, which we don't want.
300  // Re-check the current grid.
301  wxUpdateUIEvent dummy;
303  // Now run the Grid Settings... dialog
304  wxCommandEvent dummy2;
305  OnGridSettings( dummy2 );
306  }
307  else
308  {
310  }
311 
312  UpdateStatusBar();
313  m_canvas->Refresh();
314 }
315 
316 
317 void EDA_DRAW_FRAME::OnGridSettings( wxCommandEvent& aEvent )
318 {
319  DIALOG_GRID_SETTINGS dlg( this );
320 
321  if( dlg.ShowModal() == wxID_OK )
322  {
323  UpdateStatusBar();
324  GetCanvas()->Refresh();
325  }
326 }
327 
328 
330 {
331  return config()->m_Window.grid.show;
332 }
333 
334 
336 {
337  config()->m_Window.grid.show = aVisible;
338 
339  // Update the display with the new grid
340  if( GetCanvas() )
341  {
342  // Check to ensure these exist, since this function could be called before
343  // the GAL and View have been created
344  if( GetCanvas()->GetGAL() )
345  GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
346 
347  if( GetCanvas()->GetView() )
349 
350  GetCanvas()->Refresh();
351  }
352 }
353 
354 
356 {
357  if( m_zoomSelectBox == NULL )
358  return;
359 
360  double zoom = m_canvas->GetGAL()->GetZoomFactor();
361 
362  m_zoomSelectBox->Clear();
363  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
364  m_zoomSelectBox->SetSelection( 0 );
365 
366  for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i )
367  {
368  double current = config()->m_Window.zoom_factors[i];
369 
370  m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) );
371 
372  if( zoom == current )
373  m_zoomSelectBox->SetSelection( i + 1 );
374  }
375 }
376 
377 
378 void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
379 {
380  if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL )
381  return;
382 
383  int current = 0; // display Auto if no match found
384 
385  // check for a match within 1%
386  double zoom = GetCanvas()->GetGAL()->GetZoomFactor();
387 
388  for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); i++ )
389  {
390  if( std::fabs( zoom - config()->m_Window.zoom_factors[i] ) < ( zoom / 100.0 ) )
391  {
392  current = i + 1;
393  break;
394  }
395  }
396 
397  if( current != m_zoomSelectBox->GetSelection() )
398  m_zoomSelectBox->SetSelection( current );
399 }
400 
401 
402 /*
403  * Respond to selections in the toolbar zoom popup
404  */
405 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
406 {
407  wxCHECK_RET( m_zoomSelectBox, "m_zoomSelectBox uninitialized" );
408 
409  int id = m_zoomSelectBox->GetCurrentSelection();
410 
411  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
412  return;
413 
414  m_toolManager->RunAction( "common.Control.zoomPreset", true, id );
415  UpdateStatusBar();
416  m_canvas->Refresh();
417 }
418 
419 
420 void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
421 {
422  // If the window is moved to a different display, the scaling factor may change
423  double oldFactor = m_galDisplayOptions.m_scaleFactor;
425 
426  if( oldFactor != m_galDisplayOptions.m_scaleFactor && m_canvas )
427  {
428  wxSize clientSize = GetClientSize();
429  GetCanvas()->GetGAL()->ResizeScreen( clientSize.x, clientSize.y );
430  GetCanvas()->GetView()->MarkDirty();
431  }
432 
433  aEvent.Skip();
434 }
435 
436 
438 {
439  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
440  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
441 
442  aMenu.AddSeparator( 1000 );
443 
444  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
445  zoomMenu->SetTool( commonTools );
446  aToolMenu.AddSubMenu( zoomMenu );
447 
448  auto gridMenu = std::make_shared<GRID_MENU>( this );
449  gridMenu->SetTool( commonTools );
450  aToolMenu.AddSubMenu( gridMenu );
451 
452  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
453  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
454 }
455 
456 
457 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
458 {
459  SetStatusText( msg, 6 );
460 }
461 
462 
464 {
465  wxString line;
466 
467  line.Printf( "grid %s",
468  MessageTextFromValue( GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x, false ) );
469 
470  SetStatusText( line, 4 );
471 }
472 
473 
475 {
476  wxString msg;
477 
478  switch( m_userUnits )
479  {
480  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
481  case EDA_UNITS::MILS: msg = _( "mils" ); break;
482  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
483  default: msg = _( "Units" ); break;
484  }
485 
486  SetStatusText( msg, 5 );
487 }
488 
489 
490 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
491 {
492  m_frameSize = GetClientSize( );
493 
494  SizeEv.Skip();
495 }
496 
497 
499 {
500  SetStatusText( GetZoomLevelIndicator(), 1 );
501 
502  // Absolute and relative cursor positions are handled by overloading this function and
503  // handling the internal to user units conversion at the appropriate level.
504 
505  // refresh units display
506  DisplayUnitsMsg();
507 }
508 
509 
511 {
512  // returns a human readable value which can be displayed as zoom
513  // level indicator in dialogs.
514  double zoom = m_canvas->GetGAL()->GetZoomFactor();
515  return wxString::Format( wxT( "Z %.2f" ), zoom );
516 }
517 
518 
520 {
522 
523  COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings();
524  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
525 
526  // Read units used in dialogs and toolbars
527  SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
528 
531 
532  m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
533 
534  m_findReplaceData->SetFlags( aCfg->m_FindReplace.flags );
535  m_findReplaceData->SetFindString( aCfg->m_FindReplace.find_string );
536  m_findReplaceData->SetReplaceString( aCfg->m_FindReplace.replace_string );
537 
538  for( auto& s : aCfg->m_FindReplace.find_history )
539  m_findStringHistoryList.Add( s );
540 
541  for( auto& s : aCfg->m_FindReplace.replace_history )
543 }
544 
545 
547 {
549 
550  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
551 
552  aCfg->m_System.units = static_cast<int>( m_userUnits );
555 
556  m_galDisplayOptions.WriteConfig( *window );
557 
558  aCfg->m_FindReplace.flags = m_findReplaceData->GetFlags();
559  aCfg->m_FindReplace.find_string = m_findReplaceData->GetFindString();
560  aCfg->m_FindReplace.replace_string = m_findReplaceData->GetReplaceString();
561 
562  aCfg->m_FindReplace.find_history.clear();
563  aCfg->m_FindReplace.replace_history.clear();
564 
565  for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
566  {
567  aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
568  }
569 
570  for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
571  {
572  aCfg->m_FindReplace.replace_history.push_back(
573  m_replaceStringHistoryList[ i ].ToStdString() );
574  }
575 
576  // Save the units used in this frame
577  if( m_toolManager )
578  {
579  if( COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>() )
580  {
581  aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
582  aCfg->m_System.last_metric_units = static_cast<int>( cmnTool->GetLastMetricUnits() );
583  }
584  }
585 }
586 
587 
588 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
589  int aPadding )
590 {
591  if( m_messagePanel )
592  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
593 }
594 
595 
597 {
598  if( m_messagePanel )
600 }
601 
602 
604 {
605  if( m_messagePanel )
606  {
608 
609  for( const MSG_PANEL_ITEM& item : aList )
610  m_messagePanel->AppendMessage( item );
611  }
612 }
613 
614 
616  const wxString& aTextUpper, const wxString& aTextLower, int aPadding )
617 {
618  if( m_messagePanel )
619  {
621 
622  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
623  }
624 }
625 
626 
628 {
629  wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
630 
631  MSG_PANEL_ITEMS items;
632  aItem->GetMsgPanelInfo( this, items );
633  SetMsgPanel( items );
634 }
635 
636 
638 {
640 }
641 
642 
644 {
645  GetCanvas()->SetEvtHandlerEnabled( true );
646  GetCanvas()->StartDrawing();
647 }
648 
649 
651 {
652  GetCanvas()->SwitchBackend( aCanvasType );
654 
656 }
657 
658 
660 {
661 #ifdef __WXMAC__
662  // Cairo renderer doesn't handle Retina displays so there's really only one game
663  // in town for Mac
665 #endif
666 
669 
670  if( cfg )
671  canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
672 
673  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
674  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
675  {
676  wxASSERT( false );
678  }
679 
680  // Legacy canvas no longer supported. Switch to Cairo, and on the first instantiation
681  // the user will be prompted to switch to OpenGL
682  if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
684 
685  return canvasType;
686 }
687 
688 
690 {
691  // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
692  // have a fixed type, or do not have a option to set the canvas type (they inherit from
693  // a parent frame)
694  FRAME_T allowed_frames[] =
695  {
696  FRAME_SCH,
698  FRAME_GERBER,
700  };
701 
702  bool allow_save = false;
703 
704  for( unsigned ii = 0; ii < arrayDim( allowed_frames ); ii++ )
705  {
706  if( m_ident == allowed_frames[ii] )
707  {
708  allow_save = true;
709  break;
710  }
711  }
712 
713  if( !allow_save )
714  return false;
715 
716  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
717  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
718  {
719  wxASSERT( false );
720  return false;
721  }
722 
724 
725  if( cfg )
726  cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
727 
728  return false;
729 }
730 
731 
732 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition ) const
733 {
734  const wxPoint& gridOrigin = GetGridOrigin();
735  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
736 
737  double xOffset = fmod( gridOrigin.x, gridSize.x );
738  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
739  double yOffset = fmod( gridOrigin.y, gridSize.y );
740  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
741 
742  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
743 }
744 
745 
746 wxPoint EDA_DRAW_FRAME::GetNearestHalfGridPosition( const wxPoint& aPosition ) const
747 {
748  const wxPoint& gridOrigin = GetGridOrigin();
749  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
750 
751  double xOffset = fmod( gridOrigin.x, gridSize.x );
752  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
753  double yOffset = fmod( gridOrigin.y, gridSize.y );
754  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
755 
756  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
757 }
758 
759 
760 const BOX2I EDA_DRAW_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
761 {
762  return BOX2I();
763 }
764 
765 
767 {
768  // To be implemented by subclasses.
769 }
770 
771 
772 void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
773 {
775 }
776 
777 
778 // Find the first child dialog.
779 wxWindow* findDialog( wxWindowList& aList )
780 {
781  for( wxWindow* window : aList )
782  {
783  if( dynamic_cast<DIALOG_SHIM*>( window ) )
784  return window;
785  }
786  return NULL;
787 }
788 
789 
790 void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos )
791 {
792  bool centerView = false;
793  BOX2D r = GetCanvas()->GetView()->GetViewport();
794 
795  // Center if we're off the current view, or within 10% of its edge
796  r.Inflate( - (int) r.GetWidth() / 10 );
797 
798  if( !r.Contains( aPos ) )
799  centerView = true;
800 
801  // Center if we're behind an obscuring dialog, or within 10% of its edge
802  wxWindow* dialog = findDialog( GetChildren() );
803 
804  if( dialog )
805  {
806  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
807  dialog->GetSize() );
808  dialogRect.Inflate( dialogRect.GetWidth() / 10 );
809 
810  if( dialogRect.Contains( (wxPoint) GetCanvas()->GetView()->ToScreen( aPos ) ) )
811  centerView = true;
812  }
813 
814  if( centerView )
815  {
816  // If a dialog partly obscures the window, then center on the uncovered area.
817  if( dialog )
818  {
819  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
820  dialog->GetSize() );
821  GetCanvas()->GetView()->SetCenter( aPos, dialogRect );
822  }
823  else
824  GetCanvas()->GetView()->SetCenter( aPos );
825  }
826 
828 }
829 
830 
831 static const wxString productName = wxT( "KiCad E.D.A. " );
832 
833 void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
834  const wxString& aFullSheetName, const wxString& aFileName,
835  const TITLE_BLOCK& aTitleBlock, int aSheetCount,
836  const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
837  const wxString& aSheetLayer, bool aIsFirstPage )
838 {
839  DS_DRAW_ITEM_LIST drawList;
840 
841  drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
842  drawList.SetMilsToIUfactor( aMils2Iu );
843  drawList.SetPageNumber( aPageNumber );
844  drawList.SetSheetCount( aSheetCount );
845  drawList.SetFileName( aFileName );
846  drawList.SetSheetName( aFullSheetName );
847  drawList.SetSheetLayer( aSheetLayer );
848  drawList.SetProject( aProject );
849  drawList.SetIsFirstPage( aIsFirstPage );
850 
851  drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
852 
853  // Draw item list
854  drawList.Print( aSettings );
855 }
856 
857 
859  double aMils2Iu, const wxString &aFilename,
860  const wxString &aSheetLayer )
861 {
863  return;
864 
865  wxDC* DC = aSettings->GetPrintDC();
866  wxPoint origin = DC->GetDeviceOrigin();
867 
868  if( origin.y > 0 )
869  {
870  DC->SetDeviceOrigin( 0, 0 );
871  DC->SetAxisOrientation( true, false );
872  }
873 
874  ::PrintDrawingSheet( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
875  aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(),
876  aSheetLayer, aScreen->GetVirtualPageNumber() == 1 );
877 
878  if( origin.y > 0 )
879  {
880  DC->SetDeviceOrigin( origin.x, origin.y );
881  DC->SetAxisOrientation( true, true );
882  }
883 }
884 
885 
887 {
888  // Virtual function. Base class implementation returns an empty string.
889  return wxEmptyString;
890 }
891 
892 
893 bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
894  const wxString& wildcard, const wxString& ext,
895  bool isDirectory, bool aIsGlobal,
896  const wxString& aGlobalPath )
897 {
898  wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
899  aFilename.SetExt( ext );
900 
901  wxString dir = aGlobalPath;
902 
903 
904  if( isDirectory && doOpen )
905  {
906  if( !aIsGlobal )
907  {
908  dir = Prj().GetProjectPath();
909  }
910 
911  wxDirDialog dlg( this, prompt, dir,
912  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
913 
914  if( dlg.ShowModal() == wxID_CANCEL )
915  return false;
916 
917  aFilename = dlg.GetPath();
918  aFilename.SetExt( ext );
919  }
920  else
921  {
922  // Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
923  if( aFilename.GetName().empty() )
924  aFilename.SetName( "Library" );
925 
926  if( !aIsGlobal )
927  {
928  dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath();
929  }
930 
931  wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(),
932  wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
933  : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
934 
935  if( dlg.ShowModal() == wxID_CANCEL )
936  return false;
937 
938  aFilename = dlg.GetPath();
939  aFilename.SetExt( ext );
940  }
941 
942  return true;
943 }
944 
945 
947 {
948  // Rebuild all toolbars, and update the checked state of check tools
949  if( m_mainToolBar )
951 
952  if( m_drawToolBar ) // Drawing tools (typically on right edge of window)
954 
955  if( m_optionsToolBar ) // Options (typically on left edge of window)
957 
958  if( m_auxiliaryToolBar ) // Additional tools under main toolbar
960 }
961 
962 
964 {
965  if( !m_colorSettings )
966  {
967  COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings();
968 
969  const_cast<EDA_DRAW_FRAME*>( this )->m_colorSettings = colorSettings;
970  }
971 
972  return m_colorSettings;
973 }
974 
975 
977 {
979 
980  if( cmnTool )
981  {
982  // Tell the tool what the units used last session
983  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_imperial_units ) );
984  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_metric_units ) );
985  }
986 
987  // Tell the tool what units the frame is currently using
988  switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
989  {
990  default:
994  }
995 }
996 
997 
998 void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondaryUnits )
999 {
1001 
1002  aPrimaryUnit = GetUserUnits();
1003  aSecondaryUnits = EDA_UNITS::MILS;
1004 
1005  if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1006  {
1007  if( cmnTool )
1008  aSecondaryUnits = cmnTool->GetLastMetricUnits();
1009  else
1010  aSecondaryUnits = EDA_UNITS::MILLIMETRES;
1011  }
1012  else
1013  {
1014  if( cmnTool )
1015  aSecondaryUnits = cmnTool->GetLastImperialUnits();
1016  else
1017  aSecondaryUnits = EDA_UNITS::MILS;
1018  }
1019 }
1020 
1021 
1023 {
1025 
1026  // Nudge user to switch to OpenGL if they are on legacy or Cairo
1027  if( m_firstRunDialogSetting < 1 )
1028  {
1030  {
1031  wxString msg =
1032  _( "KiCad can use your graphics card to give you a smoother "
1033  "and faster experience. This option is turned off by "
1034  "default since it is not compatible with all computers.\n\n"
1035  "Would you like to try enabling graphics acceleration?\n\n"
1036  "If you'd like to choose later, select Accelerated Graphics "
1037  "in the Preferences menu." );
1038 
1039  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
1040 
1041  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
1042 
1043  if( dlg.ShowModal() == wxID_YES )
1044  {
1045  // Save Cairo as default in case OpenGL crashes
1047 
1048  // Switch to OpenGL, which will save the new setting if successful
1050 
1051  // Switch back to Cairo if OpenGL is not supported
1052  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
1054 
1055  HardRedraw();
1056  }
1057  else
1058  {
1059  // If they were on legacy, switch to Cairo
1061  HardRedraw();
1062  }
1063  }
1064 
1066  SaveSettings( config() );
1067  }
1068 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
virtual void ReCreateVToolbar()=0
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
Definition: ds_draw_item.h:463
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:125
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
BOX2< VECTOR2I > BOX2I
Definition: box2.h:522
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:513
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
Container for project specific data.
Definition: project.h:62
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:74
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:442
virtual const TITLE_BLOCK & GetTitleBlock() const =0
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
std::vector< wxString > find_history
Definition: app_settings.h:108
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
ACTION_TOOLBAR * m_auxiliaryToolBar
This file is part of the common library.
ACTION_TOOLBAR * m_optionsToolBar
virtual bool SwitchBackend(GAL_TYPE aGalType)
Switch method of rendering graphics.
void SetDefaultPenSize(int aPenSize)
Definition: ds_draw_item.h:436
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ds_draw_item.h:415
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus.
Definition: tool_menu.h:42
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
int GetVirtualPageNumber() const
Definition: base_screen.h:79
static constexpr GAL_TYPE GAL_FALLBACK
void SetLastUnits(EDA_UNITS aUnit)
std::vector< wxSocketBase * > m_sockets
interprocess communication
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
void OnMove(wxMoveEvent &aEvent) override
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
int GetPageCount() const
Definition: base_screen.h:76
wxArrayString m_findStringHistoryList
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:92
void ReleaseFile()
Release the current file marked in use.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
wxPoint GetNearestHalfGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
Definition: color4d.h:44
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
EDA_MSG_PANEL is a panel to display various information messages.
Definition: msgpanel.h:104
Sentinel, do not use as a parameter.
The base class for create windows for drawing purpose.
#define DEFAULT_MAX_UNDO_ITEMS
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
virtual const wxString GetProjectPath() const
Return the full path of the project.
wxChoice * m_gridSelectBox
virtual void LoadSettings()
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
std::vector< double > zoom_factors
Definition: app_settings.h:86
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:26
Auxiliary rendering target (noncached)
Definition: definitions.h:49
This file contains miscellaneous commonly used macros and functions.
const wxString & GetPageNumber() const
Definition: base_screen.cpp:78
void DisplayUnitsMsg()
Display current unit pane in the status bar.
EDA_DRAW_PANEL_GAL * m_canvas
This the frame's interface to setting GAL display options.
void Print(const RENDER_SETTINGS *aSettings)
Draws the item list created by BuildDrawItemsList.
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
virtual const PAGE_INFO & GetPageSettings() const =0
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.
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:81
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:579
BASE_SCREEN * m_currentScreen
current used SCREEN
static TOOL_ACTION gridPreset
Definition: actions.h:142
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
FIND_REPLACE m_FindReplace
Definition: app_settings.h:169
#define NULL
wxArrayString m_replaceStringHistoryList
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:58
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:574
bool IsGridVisible() const
void WriteConfig(WINDOW_SETTINGS &aCfg)
GRID_SETTINGS grid
Definition: app_settings.h:89
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid combobox.
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:455
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
bool m_showBorderAndTitleBlock
static TOOL_ACTION inchesUnits
Definition: actions.h:147
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:263
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
coord_type GetWidth() const
Definition: box2.h:197
wxChoice * m_zoomSelectBox
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, int aSheetCount, const wxString &aPageNumber, double aMils2Iu, const PROJECT *aProject, const wxString &aSheetLayer, bool aIsFirstPage)
Print the border and title block.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:151
virtual void PrintPage(const RENDER_SETTINGS *aSettings)
Print the page pointed by current screen, set by the calling print function.
std::vector< wxString > replace_history
Definition: app_settings.h:110
ACTIONS * m_actions
Definition: tools_holder.h:158
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
void ReadCommonConfig(COMMON_SETTINGS &aCommonSettings, wxWindow *aWindow)
Read GAL config options from the common config store.
Functions to provide common constants and other functions to assist in making a consistent UI.
wxWindow * findDialog(wxWindowList &aList)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:75
An interface for classes handling user events controlling the view behavior such as zooming,...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
int GetMaxUndoItems() const
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
double GetZoomFactor() const
Get the zoom factor.
wxLogTrace helper definitions.
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
wxDC * GetPrintDC() const
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Returns bbox of document with option to not include some items.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
void EraseMsgBox()
Definition: msgpanel.cpp:214
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
#define FR_HISTORY_LIST_CNT
Maximum size of the find/replace history stacks.
virtual const wxPoint & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
virtual void ResizeScreen(int aWidth, int aHeight)
Resize the canvas.
void StartDrawing()
Begin drawing if it was stopped previously.
virtual void ReCreateOptToolbar()=0
static TOOL_ACTION milsUnits
Definition: actions.h:148
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ds_draw_item.h:423
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:159
Handles action that are shared between different applications.
Definition: common_tools.h:37
COLOR_SETTINGS * m_colorSettings
The current canvas type.
const wxString GetZoomLevelIndicator() const
Return a human readable value for display in dialogs.
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
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
wxSocketServer * m_socketServer
EDA_UNITS
Definition: eda_units.h:38
const VECTOR2D & GetGridSize() const
Return the grid size.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the page layout.
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:302
void SetAutoSaveInterval(int aInterval)
static TOOL_ACTION updateUnits
Definition: actions.h:150
virtual void ReCreateHToolbar()=0
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
see class PGM_BASE
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: ds_draw_item.h:431
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
#define _(s)
Definition: 3d_actions.cpp:33
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
Default display origin transforms object.
void setupUnits(APP_SETTINGS_BASE *aCfg)
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
static void BuildChoiceList(wxArrayString *aGridsList, APP_SETTINGS_BASE *aCfg, EDA_DRAW_FRAME *aParent)
Definition: grid_menu.cpp:79
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:400
void ReadConfig(COMMON_SETTINGS &aCommonConfig, WINDOW_SETTINGS &aWindowConfig, wxWindow *aWindow)
Read application and common configs.
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
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:68
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
virtual void ReCreateAuxiliaryToolbar()
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
wxFindReplaceData * m_findReplaceData
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ds_draw_item.h:468
int GetDefaultPenWidth() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ds_draw_item.h:376
void SetUserUnits(EDA_UNITS aUnits)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
void OnGridSettings(wxCommandEvent &event)
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void UpdateStatusBar() override
Update the status bar information.
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
Update the checked item in the zoom combobox.
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Function AppendMessage appends a message to the message panel.
Definition: msgpanel.cpp:118
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
virtual void DisplayGridMsg()
Display current grid size in the status bar.
BASE_SCREEN class implementation.
Message panel definition file.
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
void ToggleUserUnits() override
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
static int GetRequiredHeight()
Function GetRequiredHeight returns the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:79
virtual void SetGridVisibility(bool aVisible)
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
Get the pair or units in current use.
long m_firstRunDialogSetting
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:598
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
void DisplayToolMsg(const wxString &msg) override
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
virtual void UpdateMsgPanel()
Redraw the message panel.
virtual wxString GetScreenDesc() const
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
static const wxString productName
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
ACTION_TOOLBAR * m_drawToolBar
File locking utilities.