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