KiCad PCB EDA Suite
eda_draw_frame.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6  * Copyright (C) 2004-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_base.h>
35 #include <lockfile.h>
36 #include <macros.h>
37 #include <page_info.h>
38 #include <paths.h>
39 #include <pgm_base.h>
40 #include <render_settings.h>
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 )
75 
76  EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate )
77 END_EVENT_TABLE()
78 
79 
80 EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
81  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
82  long aStyle, const wxString & aFrameName ) :
83  KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
84 {
85  m_socketServer = nullptr;
86  m_mainToolBar = nullptr;
87  m_drawToolBar = nullptr;
88  m_optionsToolBar = nullptr;
89  m_auxiliaryToolBar = nullptr;
90  m_gridSelectBox = nullptr;
91  m_zoomSelectBox = nullptr;
92  m_firstRunDialogSetting = 0;
93  m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
94 
95  m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
96  m_canvas = nullptr;
97  m_toolDispatcher = nullptr;
98  m_messagePanel = nullptr;
99  m_currentScreen = nullptr;
100  m_showBorderAndTitleBlock = false; // true to display reference sheet.
101  m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
102  m_showPageLimits = false;
103  m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
104  // BLACK for Pcbnew, BLACK or WHITE for Eeschema
105  m_colorSettings = nullptr;
106  m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
107  m_userUnits = EDA_UNITS::MILLIMETRES;
108  m_polarCoords = false;
109  m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
110 
111  m_auimgr.SetFlags( wxAUI_MGR_DEFAULT );
112 
113  CreateStatusBar( 8 );
114 
115  // set the size of the status bar subwindows:
116 
117  wxWindow* stsbar = GetStatusBar();
118  int spacer = KIUI::GetTextSize( wxT( "M" ), stsbar ).x * 2;
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 + spacer,
130 
131  // cursor coords
132  KIUI::GetTextSize( wxT( "X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer,
133 
134  // delta distances
135  KIUI::GetTextSize( wxT( "dx 1234.1234 dy 1234.1234 dist 1234.1234" ), stsbar ).x + spacer,
136 
137  // grid size
138  KIUI::GetTextSize( wxT( "grid X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer,
139 
140  // units display, Inches is bigger than mm
141  KIUI::GetTextSize( _( "Inches" ), stsbar ).x + spacer,
142 
143  // Size for the "Current Tool" panel; longest string from SetTool()
144  KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + spacer,
145 
146  // constraint mode
147  KIUI::GetTextSize( _( "Constrain to H, V, 45" ), stsbar ).x + spacer
148  };
149 
150  SetStatusWidths( arrayDim( dims ), dims );
151  stsbar->SetFont( KIUI::GetStatusFont( this ) );
152 
153  // Create child subwindows.
154  GetClientSize( &m_frameSize.x, &m_frameSize.y );
155  m_framePos.x = m_framePos.y = 0;
156  m_frameSize.y -= m_msgFrameHeight;
157 
158  m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ),
159  wxSize( m_frameSize.x, m_msgFrameHeight ) );
160 
161  m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
162 
163 #if wxCHECK_VERSION( 3, 1, 3 )
164  Bind( wxEVT_DPI_CHANGED,
165  [&]( wxDPIChangedEvent& )
166  {
167  wxMoveEvent dummy;
168  OnMove( dummy );
169  } );
170 #endif
171 }
172 
173 
175 {
176  delete m_socketServer;
177 
178  for( auto socket : m_sockets )
179  {
180  socket->Shutdown();
181  socket->Destroy();
182  }
183 
185 
186  delete m_actions;
187  delete m_toolManager;
188  delete m_toolDispatcher;
189  delete m_canvas;
190 
191  delete m_currentScreen;
192  m_currentScreen = nullptr;
193 
194  delete m_findReplaceData;
195 
196  m_auimgr.UnInit();
197 
198  ReleaseFile();
199 }
200 
201 
203 {
204  m_file_checker = nullptr;
205 }
206 
207 
208 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
209 {
210  m_file_checker = ::LockFile( aFileName );
211 
212  return m_file_checker && !m_file_checker->IsAnotherRunning();
213 }
214 
215 
217 {
218  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
219 
220  wxRect rect = GetScreenRect();
221  wxPoint center = rect.GetPosition() + rect.GetSize() / 2;
222 
223  if( !frame )
224  {
225  frame = Kiway().Player( FRAME_PYTHON, true, Kiway().GetTop() );
226 
227  // If we received an error in the CTOR due to Python-ness, don't crash
228  if( !frame )
229  return;
230 
231  if( !frame->IsVisible() )
232  frame->Show( true );
233 
234  // On Windows, Raise() does not bring the window on screen, when iconized
235  if( frame->IsIconized() )
236  frame->Iconize( false );
237 
238  frame->Raise();
239  frame->SetPosition( center - frame->GetSize() / 2 );
240 
241  return;
242  }
243 
244  frame->Show( !frame->IsVisible() );
245  frame->SetPosition( center - frame->GetSize() / 2 );
246 }
247 
248 
250 {
251  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
252  return frame && frame->IsVisible();
253 }
254 
255 
257 {
258  // Notify all tools the units have changed
259  if( m_toolManager )
261 
262  UpdateStatusBar();
263  UpdateMsgPanel();
264 }
265 
266 
268 {
270  {
272  m_toolManager->GetTool<COMMON_TOOLS>()->ToggleUnits( dummy );
273  }
274  else
275  {
277  : EDA_UNITS::INCHES );
279 
280  wxCommandEvent e( UNITS_CHANGED );
281  ProcessEventLocally( e );
282  }
283 }
284 
285 
286 void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
287 {
288  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
289 
290  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
291  KIGFX::VIEW_CONTROLS* viewControls = GetCanvas()->GetViewControls();
292 
294 
295  viewControls->LoadSettings();
296 
297  m_galDisplayOptions.ReadCommonConfig( *settings, this );
298 
299  // Notify all tools the preferences have changed
300  if( m_toolManager )
302 }
303 
304 
306 {
307  if( m_messagePanel )
309 }
310 
311 
313 {
314  UpdateStatusBar();
315  DisplayUnitsMsg();
316 
317  if( m_gridSelectBox == nullptr )
318  return;
319 
320  // Update grid values with the current units setting.
321  m_gridSelectBox->Clear();
322  wxArrayString gridsList;
323 
324  GRID_MENU::BuildChoiceList( &gridsList, config(), this );
325 
326  for( const wxString& grid : gridsList )
327  m_gridSelectBox->Append( grid );
328 
329  m_gridSelectBox->Append( wxT( "---" ) );
330  m_gridSelectBox->Append( _( "Edit User Grid..." ) );
331 
332  m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx );
333 }
334 
335 
336 void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
337 {
338  // No need to update the grid select box if it doesn't exist or the grid setting change
339  // was made using the select box.
340  if( m_gridSelectBox == nullptr )
341  return;
342 
343  int idx = config()->m_Window.grid.last_size_idx;
344  idx = std::max( 0, std::min( idx, (int) m_gridSelectBox->GetCount() - 1 ) );
345 
346  if( idx != m_gridSelectBox->GetSelection() )
347  m_gridSelectBox->SetSelection( idx );
348 }
349 
350 
352 {
353  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
354 }
355 
356 
357 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
358 {
359  wxCHECK_RET( m_gridSelectBox, wxT( "m_gridSelectBox uninitialized" ) );
360 
361  int idx = m_gridSelectBox->GetCurrentSelection();
362 
363  if( idx == int( m_gridSelectBox->GetCount() ) - 2 )
364  {
365  // wxWidgets will check the separator, which we don't want.
366  // Re-check the current grid.
367  wxUpdateUIEvent dummy;
369  }
370  else if( idx == int( m_gridSelectBox->GetCount() ) - 1 )
371  {
372  // wxWidgets will check the Grid Settings... entry, which we don't want.
373  // Re-check the current grid.
374  wxUpdateUIEvent dummy;
376 
377  // Give a time-slice to close the menu before opening the dialog.
378  // (Only matters on some versions of GTK.)
379  wxSafeYield();
380 
382  }
383  else
384  {
385  m_toolManager->RunAction( ACTIONS::gridPreset, true, static_cast<intptr_t>( idx ) );
386  }
387 
388  UpdateStatusBar();
389  m_canvas->Refresh();
390  // Needed on Windows because clicking on m_gridSelectBox remove the focus from m_canvas
391  // (Windows specific
392  m_canvas->SetFocus();
393 }
394 
395 
396 void EDA_DRAW_FRAME::OnGridSettings( wxCommandEvent& aEvent )
397 {
398  DIALOG_GRID_SETTINGS dlg( this );
399 
400  if( dlg.ShowModal() == wxID_OK )
401  {
402  UpdateStatusBar();
403  GetCanvas()->Refresh();
404  }
405 }
406 
407 
409 {
410  return config()->m_Window.grid.show;
411 }
412 
413 
415 {
416  config()->m_Window.grid.show = aVisible;
417 
418  // Update the display with the new grid
419  if( GetCanvas() )
420  {
421  // Check to ensure these exist, since this function could be called before
422  // the GAL and View have been created
423  if( GetCanvas()->GetGAL() )
424  GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
425 
426  if( GetCanvas()->GetView() )
428 
429  GetCanvas()->Refresh();
430  }
431 }
432 
433 
435 {
436  if( m_zoomSelectBox == nullptr )
437  return;
438 
439  double zoom = m_canvas->GetGAL()->GetZoomFactor();
440 
441  m_zoomSelectBox->Clear();
442  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
443  m_zoomSelectBox->SetSelection( 0 );
444 
445  for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i )
446  {
447  double current = config()->m_Window.zoom_factors[i];
448 
449  m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) );
450 
451  if( zoom == current )
452  m_zoomSelectBox->SetSelection( i + 1 );
453  }
454 }
455 
456 
457 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
458 {
459  wxCHECK_RET( m_zoomSelectBox, wxT( "m_zoomSelectBox uninitialized" ) );
460 
461  int id = m_zoomSelectBox->GetCurrentSelection();
462 
463  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
464  return;
465 
466  m_toolManager->RunAction( ACTIONS::zoomPreset, true, static_cast<intptr_t>( id ) );
467  UpdateStatusBar();
468  m_canvas->Refresh();
469  // Needed on Windows because clicking on m_zoomSelectBox remove the focus from m_canvas
470  // (Windows specific
471  m_canvas->SetFocus();
472 }
473 
474 
475 void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
476 {
477  // If the window is moved to a different display, the scaling factor may change
478  double oldFactor = m_galDisplayOptions.m_scaleFactor;
480 
481  if( oldFactor != m_galDisplayOptions.m_scaleFactor && m_canvas )
482  {
483  wxSize clientSize = GetClientSize();
484  GetCanvas()->GetGAL()->ResizeScreen( clientSize.x, clientSize.y );
485  GetCanvas()->GetView()->MarkDirty();
486  }
487 
488  aEvent.Skip();
489 }
490 
491 
493 {
494  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
495  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
496 
497  aMenu.AddSeparator( 1000 );
498 
499  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
500  zoomMenu->SetTool( commonTools );
501  aToolMenu.AddSubMenu( zoomMenu );
502 
503  auto gridMenu = std::make_shared<GRID_MENU>( this );
504  gridMenu->SetTool( commonTools );
505  aToolMenu.AddSubMenu( gridMenu );
506 
507  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
508  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
509 }
510 
511 
512 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
513 {
514  SetStatusText( msg, 6 );
515 }
516 
517 
518 void EDA_DRAW_FRAME::DisplayConstraintsMsg( const wxString& msg )
519 {
520  SetStatusText( msg, 7 );
521 }
522 
523 
525 {
526  wxString line;
527 
528  line.Printf( wxT( "grid %s" ),
529  MessageTextFromValue( GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x,
530  false ) );
531 
532  SetStatusText( line, 4 );
533 }
534 
535 
537 {
538  wxString msg;
539 
540  switch( m_userUnits )
541  {
542  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
543  case EDA_UNITS::MILS: msg = _( "mils" ); break;
544  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
545  default: msg = _( "Units" ); break;
546  }
547 
548  SetStatusText( msg, 5 );
549 }
550 
551 
552 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
553 {
554  EDA_BASE_FRAME::OnSize( SizeEv );
555 
556  m_frameSize = GetClientSize( );
557 
558  SizeEv.Skip();
559 }
560 
561 
563 {
564  SetStatusText( GetZoomLevelIndicator(), 1 );
565 
566  // Absolute and relative cursor positions are handled by overloading this function and
567  // handling the internal to user units conversion at the appropriate level.
568 
569  // refresh units display
570  DisplayUnitsMsg();
571 }
572 
573 
575 {
576  // returns a human readable value which can be displayed as zoom
577  // level indicator in dialogs.
578  double zoom = m_canvas->GetGAL()->GetZoomFactor();
579  return wxString::Format( wxT( "Z %.2f" ), zoom );
580 }
581 
582 
584 {
586 
587  COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings();
588  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
589 
590  // Read units used in dialogs and toolbars
591  SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
592 
595 
596  m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
597 
598  m_findReplaceData->SetFlags( aCfg->m_FindReplace.flags );
599  m_findReplaceData->SetFindString( aCfg->m_FindReplace.find_string );
600  m_findReplaceData->SetReplaceString( aCfg->m_FindReplace.replace_string );
601 
602  for( auto& s : aCfg->m_FindReplace.find_history )
603  m_findStringHistoryList.Add( s );
604 
605  for( auto& s : aCfg->m_FindReplace.replace_history )
607 }
608 
609 
611 {
613 
614  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
615 
616  aCfg->m_System.units = static_cast<int>( m_userUnits );
619 
620  m_galDisplayOptions.WriteConfig( *window );
621 
622  aCfg->m_FindReplace.flags = m_findReplaceData->GetFlags();
623  aCfg->m_FindReplace.find_string = m_findReplaceData->GetFindString();
624  aCfg->m_FindReplace.replace_string = m_findReplaceData->GetReplaceString();
625 
626  aCfg->m_FindReplace.find_history.clear();
627  aCfg->m_FindReplace.replace_history.clear();
628 
629  for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
630  {
631  aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
632  }
633 
634  for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
635  {
636  aCfg->m_FindReplace.replace_history.push_back(
637  m_replaceStringHistoryList[ i ].ToStdString() );
638  }
639 
640  // Save the units used in this frame
641  if( m_toolManager )
642  {
643  if( COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>() )
644  {
645  aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
646  aCfg->m_System.last_metric_units = static_cast<int>( cmnTool->GetLastMetricUnits() );
647  }
648  }
649 }
650 
651 
652 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
653  int aPadding )
654 {
655  if( m_messagePanel )
656  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
657 }
658 
659 
661 {
662  if( m_messagePanel )
664 }
665 
666 
667 void EDA_DRAW_FRAME::SetMsgPanel( const std::vector<MSG_PANEL_ITEM>& aList )
668 {
669  if( m_messagePanel )
670  {
672 
673  for( const MSG_PANEL_ITEM& item : aList )
674  m_messagePanel->AppendMessage( item );
675  }
676 }
677 
678 
679 void EDA_DRAW_FRAME::SetMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
680  int aPadding )
681 {
682  if( m_messagePanel )
683  {
685 
686  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
687  }
688 }
689 
690 
692 {
693  wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
694 
695  std::vector<MSG_PANEL_ITEM> items;
696  aItem->GetMsgPanelInfo( this, items );
697  SetMsgPanel( items );
698 }
699 
700 
702 {
704 }
705 
706 
708 {
709  GetCanvas()->SetEvtHandlerEnabled( true );
710  GetCanvas()->StartDrawing();
711 }
712 
713 
715 {
716  GetCanvas()->SwitchBackend( aCanvasType );
718 
720 }
721 
722 
724 {
725 #ifdef __WXMAC__
726  // Cairo renderer doesn't handle Retina displays so there's really only one game
727  // in town for Mac
729 #endif
730 
733 
734  if( cfg )
735  canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
736 
737  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
738  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
739  {
740  wxASSERT( false );
742  }
743 
744  // Legacy canvas no longer supported. Switch to OpenGL, falls back to Cairo on failure
745  if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
747 
748  return canvasType;
749 }
750 
751 
753 {
754  // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
755  // have a fixed type, or do not have a option to set the canvas type (they inherit from
756  // a parent frame)
757  FRAME_T allowed_frames[] =
758  {
761  FRAME_GERBER,
763  };
764 
765  bool allow_save = false;
766 
767  for( unsigned ii = 0; ii < arrayDim( allowed_frames ); ii++ )
768  {
769  if( m_ident == allowed_frames[ii] )
770  {
771  allow_save = true;
772  break;
773  }
774  }
775 
776  if( !allow_save )
777  return false;
778 
779  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
780  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
781  {
782  wxASSERT( false );
783  return false;
784  }
785 
787 
788  if( cfg )
789  cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
790 
791  return false;
792 }
793 
794 
795 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition ) const
796 {
797  const wxPoint& gridOrigin = GetGridOrigin();
798  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
799 
800  double xOffset = fmod( gridOrigin.x, gridSize.x );
801  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
802  double yOffset = fmod( gridOrigin.y, gridSize.y );
803  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
804 
805  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
806 }
807 
808 
809 wxPoint EDA_DRAW_FRAME::GetNearestHalfGridPosition( const wxPoint& aPosition ) const
810 {
811  const wxPoint& gridOrigin = GetGridOrigin();
812  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
813 
814  double xOffset = fmod( gridOrigin.x, gridSize.x );
815  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
816  double yOffset = fmod( gridOrigin.y, gridSize.y );
817  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
818 
819  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
820 }
821 
822 
823 const BOX2I EDA_DRAW_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
824 {
825  return BOX2I();
826 }
827 
828 
830 {
831  // To be implemented by subclasses.
832 }
833 
834 
835 void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
836 {
838 }
839 
840 
841 // Find the first child dialog.
842 std::vector<wxWindow*> EDA_DRAW_FRAME::findDialogs()
843 {
844  std::vector<wxWindow*> dialogs;
845 
846  for( wxWindow* window : GetChildren() )
847  {
848  if( dynamic_cast<DIALOG_SHIM*>( window ) )
849  dialogs.push_back( window );
850  }
851 
852  return dialogs;
853 }
854 
855 
856 void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos )
857 {
858  bool centerView = false;
859  BOX2D r = GetCanvas()->GetView()->GetViewport();
860 
861  // Center if we're off the current view, or within 10% of its edge
862  r.Inflate( - (int) r.GetWidth() / 10 );
863 
864  if( !r.Contains( aPos ) )
865  centerView = true;
866 
867  std::vector<BOX2D> dialogScreenRects;
868 
869  for( wxWindow* dialog : findDialogs() )
870  {
871  dialogScreenRects.emplace_back( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
872  dialog->GetSize() );
873  }
874 
875  // Center if we're behind an obscuring dialog, or within 10% of its edge
876  for( BOX2D rect : dialogScreenRects )
877  {
878  rect.Inflate( rect.GetWidth() / 10 );
879 
880  if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
881  centerView = true;
882  }
883 
884  if( centerView )
885  {
886  try
887  {
888  GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
889  }
890  catch( const ClipperLib::clipperException& exc )
891  {
892  wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
893  exc.what() );
894  }
895  }
896 
898 }
899 
900 
901 static const wxString productName = wxT( "KiCad E.D.A. " );
902 
903 
904 void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
905  const wxString& aFullSheetName, const wxString& aFileName,
906  const TITLE_BLOCK& aTitleBlock, int aSheetCount,
907  const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
908  const wxString& aSheetLayer, bool aIsFirstPage )
909 {
910  DS_DRAW_ITEM_LIST drawList;
911 
912  drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
913  drawList.SetMilsToIUfactor( aMils2Iu );
914  drawList.SetPageNumber( aPageNumber );
915  drawList.SetSheetCount( aSheetCount );
916  drawList.SetFileName( aFileName );
917  drawList.SetSheetName( aFullSheetName );
918  drawList.SetSheetLayer( aSheetLayer );
919  drawList.SetProject( aProject );
920  drawList.SetIsFirstPage( aIsFirstPage );
921 
922  drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
923 
924  // Draw item list
925  drawList.Print( aSettings );
926 }
927 
928 
930  double aMils2Iu, const wxString &aFilename,
931  const wxString &aSheetLayer )
932 {
934  return;
935 
936  wxDC* DC = aSettings->GetPrintDC();
937  wxPoint origin = DC->GetDeviceOrigin();
938 
939  if( origin.y > 0 )
940  {
941  DC->SetDeviceOrigin( 0, 0 );
942  DC->SetAxisOrientation( true, false );
943  }
944 
945  ::PrintDrawingSheet( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
946  aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(),
947  aSheetLayer, aScreen->GetVirtualPageNumber() == 1 );
948 
949  if( origin.y > 0 )
950  {
951  DC->SetDeviceOrigin( origin.x, origin.y );
952  DC->SetAxisOrientation( true, true );
953  }
954 }
955 
956 
958 {
959  // Virtual function. Base class implementation returns an empty string.
960  return wxEmptyString;
961 }
962 
963 
964 bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
965  const wxString& wildcard, const wxString& ext,
966  bool isDirectory, bool aIsGlobal,
967  const wxString& aGlobalPath )
968 {
969  wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
970  aFilename.SetExt( ext );
971 
972  wxString dir;
973 
974  if( GetMruPath().IsEmpty() )
975  dir = aGlobalPath;
976  else
977  dir = GetMruPath();
978 
979 
980  if( isDirectory && doOpen )
981  {
982  if( !aIsGlobal && GetMruPath().IsEmpty() )
983  {
984  dir = Prj().GetProjectPath();
985  }
986 
987  wxDirDialog dlg( this, prompt, dir, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
988 
989  if( dlg.ShowModal() == wxID_CANCEL )
990  return false;
991 
992  aFilename = dlg.GetPath();
993  aFilename.SetExt( ext );
994  }
995  else
996  {
997  // Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
998  if( aFilename.GetName().empty() )
999  aFilename.SetName( wxT( "Library" ) );
1000 
1001  if( !aIsGlobal && GetMruPath().IsEmpty() )
1002  {
1003  dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath();
1004  }
1005 
1006  wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(),
1007  wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
1008  : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
1009 
1010  if( dlg.ShowModal() == wxID_CANCEL )
1011  return false;
1012 
1013  aFilename = dlg.GetPath();
1014  aFilename.SetExt( ext );
1015  }
1016 
1017  SetMruPath( aFilename.GetPath() );
1018 
1019  return true;
1020 }
1021 
1022 
1024 {
1025  // Rebuild all toolbars, and update the checked state of check tools
1026  if( m_mainToolBar )
1027  ReCreateHToolbar();
1028 
1029  if( m_drawToolBar ) // Drawing tools (typically on right edge of window)
1030  ReCreateVToolbar();
1031 
1032  if( m_optionsToolBar ) // Options (typically on left edge of window)
1034 
1035  if( m_auxiliaryToolBar ) // Additional tools under main toolbar
1037 }
1038 
1039 
1041 {
1042  if( !m_colorSettings )
1043  {
1044  COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings();
1045 
1046  const_cast<EDA_DRAW_FRAME*>( this )->m_colorSettings = colorSettings;
1047  }
1048 
1049  return m_colorSettings;
1050 }
1051 
1052 
1054 {
1056 
1057  if( cmnTool )
1058  {
1059  // Tell the tool what the units used last session
1060  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_imperial_units ) );
1061  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_metric_units ) );
1062  }
1063 
1064  // Tell the tool what units the frame is currently using
1065  switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
1066  {
1067  default:
1071  }
1072 }
1073 
1074 
1075 void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondaryUnits )
1076 {
1078 
1079  aPrimaryUnit = GetUserUnits();
1080  aSecondaryUnits = EDA_UNITS::MILS;
1081 
1082  if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1083  {
1084  if( cmnTool )
1085  aSecondaryUnits = cmnTool->GetLastMetricUnits();
1086  else
1087  aSecondaryUnits = EDA_UNITS::MILLIMETRES;
1088  }
1089  else
1090  {
1091  if( cmnTool )
1092  aSecondaryUnits = cmnTool->GetLastImperialUnits();
1093  else
1094  aSecondaryUnits = EDA_UNITS::MILS;
1095  }
1096 }
1097 
1098 
1100 {
1102 
1103  // Nudge user to switch to OpenGL if they are on legacy or Cairo
1104  if( m_firstRunDialogSetting < 1 )
1105  {
1107  {
1108  // Save Cairo as default in case OpenGL crashes
1110 
1111  // Switch to OpenGL, which will save the new setting if successful
1113 
1114  // Switch back to Cairo if OpenGL is not supported
1115  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
1117 
1118  HardRedraw();
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 }
void DisplayConstraintsMsg(const wxString &msg)
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:512
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
void SetMruPath(const wxString &aPath)
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
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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
static int GetRequiredHeight(wxWindow *aWindow)
Return the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:63
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
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.
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:393
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:100
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:205
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:72
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 ...
wxString GetMruPath() const
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:578
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:70
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:609
bool IsGridVisible() const
void WriteConfig(WINDOW_SETTINGS &aCfg)
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
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:213
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
wxChoice * m_zoomSelectBox
static TOOL_ACTION updatePreferences
Definition: actions.h:170
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.
Generic, UI-independent tool event.
Definition: tool_event.h:152
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.
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.
virtual void SetFocus() override
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:198
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.
E_SERIE r
Definition: eserie.cpp:41
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
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
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
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
std::vector< wxWindow * > findDialogs()
static void BuildChoiceList(wxArrayString *aGridsList, APP_SETTINGS_BASE *aCfg, EDA_DRAW_FRAME *aParent)
Definition: grid_menu.cpp:85
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:99
virtual void ReCreateAuxiliaryToolbar()
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
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:92
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.
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:94
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
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:633
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.