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/event.h>
59 #include <wx/snglinst.h>
61 #include <widgets/ui_common.h>
62 #include <wx/dirdlg.h>
63 #include <wx/filedlg.h>
64 #include <wx/msgdlg.h>
65 
66 #define FR_HISTORY_LIST_CNT 10
67 
68 
69 BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
72 
73  EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate )
74 END_EVENT_TABLE()
75 
76 
77 EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
78  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
79  long aStyle, const wxString & aFrameName ) :
80  KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
81 {
82  m_socketServer = nullptr;
83  m_mainToolBar = NULL;
84  m_drawToolBar = NULL;
85  m_optionsToolBar = NULL;
86  m_auxiliaryToolBar = NULL;
87  m_gridSelectBox = NULL;
88  m_zoomSelectBox = NULL;
89  m_firstRunDialogSetting = 0;
90  m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
91 
92  m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
93  m_canvas = NULL;
94  m_toolDispatcher = NULL;
95  m_messagePanel = NULL;
96  m_currentScreen = NULL;
97  m_showBorderAndTitleBlock = false; // true to display reference sheet.
98  m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
99  m_showPageLimits = false;
100  m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
101  // BLACK for Pcbnew, BLACK or WHITE for Eeschema
102  m_colorSettings = nullptr;
103  m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
104  m_userUnits = EDA_UNITS::MILLIMETRES;
105  m_polarCoords = false;
106  m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
107 
108  m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
109 
110  CreateStatusBar( 7 );
111 
112  // set the size of the status bar subwindows:
113 
114  wxWindow* stsbar = GetStatusBar();
115 
116  int dims[] = {
117 
118  // remainder of status bar on far left is set to a default or whatever is left over.
119  -1,
120 
121  // When using GetTextSize() remember the width of character '1' is not the same
122  // as the width of '0' unless the font is fixed width, and it usually won't be.
123 
124  // zoom:
125  KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
126 
127  // cursor coords
128  KIUI::GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
129 
130  // delta distances
131  KIUI::GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
132 
133  // grid size
134  KIUI::GetTextSize( wxT( "grid X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
135 
136  // units display, Inches is bigger than mm
137  KIUI::GetTextSize( _( "Inches" ), stsbar ).x + 10,
138 
139  // Size for the "Current Tool" panel; longest string from SetTool()
140  KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
141  };
142 
143  SetStatusWidths( arrayDim( dims ), dims );
144 
145  // Create child subwindows.
146  GetClientSize( &m_frameSize.x, &m_frameSize.y );
147  m_framePos.x = m_framePos.y = 0;
148  m_frameSize.y -= m_msgFrameHeight;
149 
150  m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ),
151  wxSize( m_frameSize.x, m_msgFrameHeight ) );
152 
153  m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
154 }
155 
156 
158 {
159  delete m_socketServer;
160 
161  for( auto socket : m_sockets )
162  {
163  socket->Shutdown();
164  socket->Destroy();
165  }
166 
168 
169  delete m_actions;
170  delete m_toolManager;
171  delete m_toolDispatcher;
172  delete m_canvas;
173 
174  delete m_currentScreen;
176 
177  delete m_findReplaceData;
178 
179  m_auimgr.UnInit();
180 
181  ReleaseFile();
182 }
183 
184 
186 {
187  m_file_checker = nullptr;
188 }
189 
190 
191 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
192 {
193  m_file_checker = ::LockFile( aFileName );
194 
195  return bool( m_file_checker );
196 }
197 
198 
200 {
201  // Notify all tools the units have changed
202  if( m_toolManager )
204 
205  UpdateStatusBar();
206  UpdateMsgPanel();
207 }
208 
209 
211 {
214 
215  wxCommandEvent e( UNITS_CHANGED );
216  ProcessEventLocally( e );
217 }
218 
219 
220 void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
221 {
222  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
223 
224  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
225  KIGFX::VIEW_CONTROLS* viewControls = GetCanvas()->GetViewControls();
226 
228 
229  viewControls->LoadSettings();
230 
231  m_galDisplayOptions.ReadCommonConfig( *settings, this );
232 }
233 
234 
236 {
237  if( m_messagePanel )
239 }
240 
241 
243 {
244  UpdateStatusBar();
245  DisplayUnitsMsg();
246 
247  if( m_gridSelectBox == NULL )
248  return;
249 
250  // Update grid values with the current units setting.
251  m_gridSelectBox->Clear();
252  wxArrayString gridsList;
253 
254  GRID_MENU::BuildChoiceList( &gridsList, config(), this );
255 
256  for( const wxString& grid : gridsList )
257  m_gridSelectBox->Append( grid );
258 
259  m_gridSelectBox->Append( wxT( "---" ) );
260  m_gridSelectBox->Append( _( "Edit User Grid..." ) );
261 
262  m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx );
263 }
264 
265 
266 void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
267 {
268  // No need to update the grid select box if it doesn't exist or the grid setting change
269  // was made using the select box.
270  if( m_gridSelectBox == NULL )
271  return;
272 
273  int idx = config()->m_Window.grid.last_size_idx;
274  idx = std::max( 0, std::min( idx, (int) m_gridSelectBox->GetCount() - 1 ) );
275 
276  if( idx != m_gridSelectBox->GetSelection() )
277  m_gridSelectBox->SetSelection( idx );
278 }
279 
280 
282 {
283  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
284 }
285 
286 
287 /*
288  * Respond to selections in the toolbar grid popup
289  */
290 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
291 {
292  wxCHECK_RET( m_gridSelectBox, "m_gridSelectBox uninitialized" );
293 
294  int idx = m_gridSelectBox->GetCurrentSelection();
295 
296  if( idx == int( m_gridSelectBox->GetCount() ) - 2 )
297  {
298  // wxWidgets will check the separator, which we don't want.
299  // Re-check the current grid.
300  wxUpdateUIEvent dummy;
302  }
303  else if( idx == int( m_gridSelectBox->GetCount() ) - 1 )
304  {
305  // wxWidgets will check the Grid Settings... entry, which we don't want.
306  // Re-check the current grid.
307  wxUpdateUIEvent dummy;
309 
310  // Give a time-slice to close the menu before opening the dialog.
311  // (Only matters on some versions of GTK.)
312  wxSafeYield();
313 
315  }
316  else
317  {
319  }
320 
321  UpdateStatusBar();
322  m_canvas->Refresh();
323 }
324 
325 
326 void EDA_DRAW_FRAME::OnGridSettings( wxCommandEvent& aEvent )
327 {
328  DIALOG_GRID_SETTINGS dlg( this );
329 
330  if( dlg.ShowModal() == wxID_OK )
331  {
332  UpdateStatusBar();
333  GetCanvas()->Refresh();
334  }
335 }
336 
337 
339 {
340  return config()->m_Window.grid.show;
341 }
342 
343 
345 {
346  config()->m_Window.grid.show = aVisible;
347 
348  // Update the display with the new grid
349  if( GetCanvas() )
350  {
351  // Check to ensure these exist, since this function could be called before
352  // the GAL and View have been created
353  if( GetCanvas()->GetGAL() )
354  GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
355 
356  if( GetCanvas()->GetView() )
358 
359  GetCanvas()->Refresh();
360  }
361 }
362 
363 
365 {
366  if( m_zoomSelectBox == NULL )
367  return;
368 
369  double zoom = m_canvas->GetGAL()->GetZoomFactor();
370 
371  m_zoomSelectBox->Clear();
372  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
373  m_zoomSelectBox->SetSelection( 0 );
374 
375  for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i )
376  {
377  double current = config()->m_Window.zoom_factors[i];
378 
379  m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) );
380 
381  if( zoom == current )
382  m_zoomSelectBox->SetSelection( i + 1 );
383  }
384 }
385 
386 
387 void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
388 {
389  if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL )
390  return;
391 
392  int current = 0; // display Auto if no match found
393 
394  // check for a match within 1%
395  double zoom = GetCanvas()->GetGAL()->GetZoomFactor();
396 
397  for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); i++ )
398  {
399  if( std::fabs( zoom - config()->m_Window.zoom_factors[i] ) < ( zoom / 100.0 ) )
400  {
401  current = i + 1;
402  break;
403  }
404  }
405 
406  if( current != m_zoomSelectBox->GetSelection() )
407  m_zoomSelectBox->SetSelection( current );
408 }
409 
410 
411 /*
412  * Respond to selections in the toolbar zoom popup
413  */
414 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
415 {
416  wxCHECK_RET( m_zoomSelectBox, "m_zoomSelectBox uninitialized" );
417 
418  int id = m_zoomSelectBox->GetCurrentSelection();
419 
420  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
421  return;
422 
423  m_toolManager->RunAction( "common.Control.zoomPreset", true, id );
424  UpdateStatusBar();
425  m_canvas->Refresh();
426 }
427 
428 
429 void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
430 {
431  // If the window is moved to a different display, the scaling factor may change
432  double oldFactor = m_galDisplayOptions.m_scaleFactor;
434 
435  if( oldFactor != m_galDisplayOptions.m_scaleFactor && m_canvas )
436  {
437  wxSize clientSize = GetClientSize();
438  GetCanvas()->GetGAL()->ResizeScreen( clientSize.x, clientSize.y );
439  GetCanvas()->GetView()->MarkDirty();
440  }
441 
442  aEvent.Skip();
443 }
444 
445 
447 {
448  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
449  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
450 
451  aMenu.AddSeparator( 1000 );
452 
453  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
454  zoomMenu->SetTool( commonTools );
455  aToolMenu.AddSubMenu( zoomMenu );
456 
457  auto gridMenu = std::make_shared<GRID_MENU>( this );
458  gridMenu->SetTool( commonTools );
459  aToolMenu.AddSubMenu( gridMenu );
460 
461  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
462  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
463 }
464 
465 
466 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
467 {
468  SetStatusText( msg, 6 );
469 }
470 
471 
473 {
474  wxString line;
475 
476  line.Printf( "grid %s",
477  MessageTextFromValue( GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x, false ) );
478 
479  SetStatusText( line, 4 );
480 }
481 
482 
484 {
485  wxString msg;
486 
487  switch( m_userUnits )
488  {
489  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
490  case EDA_UNITS::MILS: msg = _( "mils" ); break;
491  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
492  default: msg = _( "Units" ); break;
493  }
494 
495  SetStatusText( msg, 5 );
496 }
497 
498 
499 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
500 {
501  m_frameSize = GetClientSize( );
502 
503  SizeEv.Skip();
504 }
505 
506 
508 {
509  SetStatusText( GetZoomLevelIndicator(), 1 );
510 
511  // Absolute and relative cursor positions are handled by overloading this function and
512  // handling the internal to user units conversion at the appropriate level.
513 
514  // refresh units display
515  DisplayUnitsMsg();
516 }
517 
518 
520 {
521  // returns a human readable value which can be displayed as zoom
522  // level indicator in dialogs.
523  double zoom = m_canvas->GetGAL()->GetZoomFactor();
524  return wxString::Format( wxT( "Z %.2f" ), zoom );
525 }
526 
527 
529 {
531 
532  COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings();
533  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
534 
535  // Read units used in dialogs and toolbars
536  SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
537 
540 
541  m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
542 
543  m_findReplaceData->SetFlags( aCfg->m_FindReplace.flags );
544  m_findReplaceData->SetFindString( aCfg->m_FindReplace.find_string );
545  m_findReplaceData->SetReplaceString( aCfg->m_FindReplace.replace_string );
546 
547  for( auto& s : aCfg->m_FindReplace.find_history )
548  m_findStringHistoryList.Add( s );
549 
550  for( auto& s : aCfg->m_FindReplace.replace_history )
552 }
553 
554 
556 {
558 
559  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
560 
561  aCfg->m_System.units = static_cast<int>( m_userUnits );
564 
565  m_galDisplayOptions.WriteConfig( *window );
566 
567  aCfg->m_FindReplace.flags = m_findReplaceData->GetFlags();
568  aCfg->m_FindReplace.find_string = m_findReplaceData->GetFindString();
569  aCfg->m_FindReplace.replace_string = m_findReplaceData->GetReplaceString();
570 
571  aCfg->m_FindReplace.find_history.clear();
572  aCfg->m_FindReplace.replace_history.clear();
573 
574  for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
575  {
576  aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
577  }
578 
579  for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
580  {
581  aCfg->m_FindReplace.replace_history.push_back(
582  m_replaceStringHistoryList[ i ].ToStdString() );
583  }
584 
585  // Save the units used in this frame
586  if( m_toolManager )
587  {
588  if( COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>() )
589  {
590  aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
591  aCfg->m_System.last_metric_units = static_cast<int>( cmnTool->GetLastMetricUnits() );
592  }
593  }
594 }
595 
596 
597 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
598  int aPadding )
599 {
600  if( m_messagePanel )
601  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
602 }
603 
604 
606 {
607  if( m_messagePanel )
609 }
610 
611 
613 {
614  if( m_messagePanel )
615  {
617 
618  for( const MSG_PANEL_ITEM& item : aList )
619  m_messagePanel->AppendMessage( item );
620  }
621 }
622 
623 
625  const wxString& aTextUpper, const wxString& aTextLower, int aPadding )
626 {
627  if( m_messagePanel )
628  {
630 
631  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
632  }
633 }
634 
635 
637 {
638  wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
639 
640  MSG_PANEL_ITEMS items;
641  aItem->GetMsgPanelInfo( this, items );
642  SetMsgPanel( items );
643 }
644 
645 
647 {
649 }
650 
651 
653 {
654  GetCanvas()->SetEvtHandlerEnabled( true );
655  GetCanvas()->StartDrawing();
656 }
657 
658 
660 {
661  GetCanvas()->SwitchBackend( aCanvasType );
663 
665 }
666 
667 
669 {
670 #ifdef __WXMAC__
671  // Cairo renderer doesn't handle Retina displays so there's really only one game
672  // in town for Mac
674 #endif
675 
678 
679  if( cfg )
680  canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
681 
682  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
683  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
684  {
685  wxASSERT( false );
687  }
688 
689  // Legacy canvas no longer supported. Switch to Cairo, and on the first instantiation
690  // the user will be prompted to switch to OpenGL
691  if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
693 
694  return canvasType;
695 }
696 
697 
699 {
700  // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
701  // have a fixed type, or do not have a option to set the canvas type (they inherit from
702  // a parent frame)
703  FRAME_T allowed_frames[] =
704  {
705  FRAME_SCH,
707  FRAME_GERBER,
709  };
710 
711  bool allow_save = false;
712 
713  for( unsigned ii = 0; ii < arrayDim( allowed_frames ); ii++ )
714  {
715  if( m_ident == allowed_frames[ii] )
716  {
717  allow_save = true;
718  break;
719  }
720  }
721 
722  if( !allow_save )
723  return false;
724 
725  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
726  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
727  {
728  wxASSERT( false );
729  return false;
730  }
731 
733 
734  if( cfg )
735  cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
736 
737  return false;
738 }
739 
740 
741 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition ) const
742 {
743  const wxPoint& gridOrigin = GetGridOrigin();
744  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
745 
746  double xOffset = fmod( gridOrigin.x, gridSize.x );
747  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
748  double yOffset = fmod( gridOrigin.y, gridSize.y );
749  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
750 
751  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
752 }
753 
754 
755 wxPoint EDA_DRAW_FRAME::GetNearestHalfGridPosition( const wxPoint& aPosition ) const
756 {
757  const wxPoint& gridOrigin = GetGridOrigin();
758  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
759 
760  double xOffset = fmod( gridOrigin.x, gridSize.x );
761  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
762  double yOffset = fmod( gridOrigin.y, gridSize.y );
763  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
764 
765  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
766 }
767 
768 
769 const BOX2I EDA_DRAW_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
770 {
771  return BOX2I();
772 }
773 
774 
776 {
777  // To be implemented by subclasses.
778 }
779 
780 
781 void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
782 {
784 }
785 
786 
787 // Find the first child dialog.
788 wxWindow* findDialog( wxWindowList& aList )
789 {
790  for( wxWindow* window : aList )
791  {
792  if( dynamic_cast<DIALOG_SHIM*>( window ) )
793  return window;
794  }
795  return NULL;
796 }
797 
798 
799 void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos )
800 {
801  bool centerView = false;
802  BOX2D r = GetCanvas()->GetView()->GetViewport();
803 
804  // Center if we're off the current view, or within 10% of its edge
805  r.Inflate( - (int) r.GetWidth() / 10 );
806 
807  if( !r.Contains( aPos ) )
808  centerView = true;
809 
810  // Center if we're behind an obscuring dialog, or within 10% of its edge
811  wxWindow* dialog = findDialog( GetChildren() );
812 
813  if( dialog )
814  {
815  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
816  dialog->GetSize() );
817  dialogRect.Inflate( dialogRect.GetWidth() / 10 );
818 
819  if( dialogRect.Contains( (wxPoint) GetCanvas()->GetView()->ToScreen( aPos ) ) )
820  centerView = true;
821  }
822 
823  if( centerView )
824  {
825  // If a dialog partly obscures the window, then center on the uncovered area.
826  if( dialog )
827  {
828  wxRect dialogRect( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
829  dialog->GetSize() );
830  GetCanvas()->GetView()->SetCenter( aPos, dialogRect );
831  }
832  else
833  GetCanvas()->GetView()->SetCenter( aPos );
834  }
835 
837 }
838 
839 
840 static const wxString productName = wxT( "KiCad E.D.A. " );
841 
842 void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
843  const wxString& aFullSheetName, const wxString& aFileName,
844  const TITLE_BLOCK& aTitleBlock, int aSheetCount,
845  const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
846  const wxString& aSheetLayer, bool aIsFirstPage )
847 {
848  DS_DRAW_ITEM_LIST drawList;
849 
850  drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
851  drawList.SetMilsToIUfactor( aMils2Iu );
852  drawList.SetPageNumber( aPageNumber );
853  drawList.SetSheetCount( aSheetCount );
854  drawList.SetFileName( aFileName );
855  drawList.SetSheetName( aFullSheetName );
856  drawList.SetSheetLayer( aSheetLayer );
857  drawList.SetProject( aProject );
858  drawList.SetIsFirstPage( aIsFirstPage );
859 
860  drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
861 
862  // Draw item list
863  drawList.Print( aSettings );
864 }
865 
866 
868  double aMils2Iu, const wxString &aFilename,
869  const wxString &aSheetLayer )
870 {
872  return;
873 
874  wxDC* DC = aSettings->GetPrintDC();
875  wxPoint origin = DC->GetDeviceOrigin();
876 
877  if( origin.y > 0 )
878  {
879  DC->SetDeviceOrigin( 0, 0 );
880  DC->SetAxisOrientation( true, false );
881  }
882 
883  ::PrintDrawingSheet( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
884  aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(),
885  aSheetLayer, aScreen->GetVirtualPageNumber() == 1 );
886 
887  if( origin.y > 0 )
888  {
889  DC->SetDeviceOrigin( origin.x, origin.y );
890  DC->SetAxisOrientation( true, true );
891  }
892 }
893 
894 
896 {
897  // Virtual function. Base class implementation returns an empty string.
898  return wxEmptyString;
899 }
900 
901 
902 bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
903  const wxString& wildcard, const wxString& ext,
904  bool isDirectory, bool aIsGlobal,
905  const wxString& aGlobalPath )
906 {
907  wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
908  aFilename.SetExt( ext );
909 
910  wxString dir = aGlobalPath;
911 
912 
913  if( isDirectory && doOpen )
914  {
915  if( !aIsGlobal )
916  {
917  dir = Prj().GetProjectPath();
918  }
919 
920  wxDirDialog dlg( this, prompt, dir,
921  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
922 
923  if( dlg.ShowModal() == wxID_CANCEL )
924  return false;
925 
926  aFilename = dlg.GetPath();
927  aFilename.SetExt( ext );
928  }
929  else
930  {
931  // Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
932  if( aFilename.GetName().empty() )
933  aFilename.SetName( "Library" );
934 
935  if( !aIsGlobal )
936  {
937  dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath();
938  }
939 
940  wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(),
941  wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
942  : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
943 
944  if( dlg.ShowModal() == wxID_CANCEL )
945  return false;
946 
947  aFilename = dlg.GetPath();
948  aFilename.SetExt( ext );
949  }
950 
951  return true;
952 }
953 
954 
956 {
957  // Rebuild all toolbars, and update the checked state of check tools
958  if( m_mainToolBar )
960 
961  if( m_drawToolBar ) // Drawing tools (typically on right edge of window)
963 
964  if( m_optionsToolBar ) // Options (typically on left edge of window)
966 
967  if( m_auxiliaryToolBar ) // Additional tools under main toolbar
969 }
970 
971 
973 {
974  if( !m_colorSettings )
975  {
976  COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings();
977 
978  const_cast<EDA_DRAW_FRAME*>( this )->m_colorSettings = colorSettings;
979  }
980 
981  return m_colorSettings;
982 }
983 
984 
986 {
988 
989  if( cmnTool )
990  {
991  // Tell the tool what the units used last session
992  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_imperial_units ) );
993  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_metric_units ) );
994  }
995 
996  // Tell the tool what units the frame is currently using
997  switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
998  {
999  default:
1003  }
1004 }
1005 
1006 
1007 void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondaryUnits )
1008 {
1010 
1011  aPrimaryUnit = GetUserUnits();
1012  aSecondaryUnits = EDA_UNITS::MILS;
1013 
1014  if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1015  {
1016  if( cmnTool )
1017  aSecondaryUnits = cmnTool->GetLastMetricUnits();
1018  else
1019  aSecondaryUnits = EDA_UNITS::MILLIMETRES;
1020  }
1021  else
1022  {
1023  if( cmnTool )
1024  aSecondaryUnits = cmnTool->GetLastImperialUnits();
1025  else
1026  aSecondaryUnits = EDA_UNITS::MILS;
1027  }
1028 }
1029 
1030 
1032 {
1034 
1035  // Nudge user to switch to OpenGL if they are on legacy or Cairo
1036  if( m_firstRunDialogSetting < 1 )
1037  {
1039  {
1040  wxString msg =
1041  _( "KiCad can use your graphics card to give you a smoother "
1042  "and faster experience. This option is turned off by "
1043  "default since it is not compatible with all computers.\n\n"
1044  "Would you like to try enabling graphics acceleration?\n\n"
1045  "If you'd like to choose later, select Accelerated Graphics "
1046  "in the Preferences menu." );
1047 
1048  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
1049 
1050  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
1051 
1052  if( dlg.ShowModal() == wxID_YES )
1053  {
1054  // Save Cairo as default in case OpenGL crashes
1056 
1057  // Switch to OpenGL, which will save the new setting if successful
1059 
1060  // Switch back to Cairo if OpenGL is not supported
1061  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
1063 
1064  HardRedraw();
1065  }
1066  else
1067  {
1068  // If they were on legacy, switch to Cairo
1070  HardRedraw();
1071  }
1072  }
1073 
1075  SaveSettings( config() );
1076  }
1077 }
1078 
1079 
1080 void EDA_DRAW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1081 {
1082  // Force a refresh of the message panel to ensure that the text is the right color
1083  // when the window activates
1084  if( !IsIconized() )
1085  m_messagePanel->Refresh();
1086 }
1087 
1088 
1089 void EDA_DRAW_FRAME::onActivate( wxActivateEvent& aEvent )
1090 {
1091  handleActivateEvent( aEvent );
1092 
1093  aEvent.Skip();
1094 }
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:90
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:514
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.
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
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.
Definition: project.cpp:123
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:206
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:580
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:264
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:223
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.
Definition: project.cpp:135
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
void onActivate(wxActivateEvent &aEvent)
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:150
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
static TOOL_ACTION gridProperties
Definition: actions.h:144
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:119
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:80
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.