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_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 )
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( this );
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  stsbar->SetFont( KIUI::GetStatusFont( this ) );
149 
150  // Create child subwindows.
151  GetClientSize( &m_frameSize.x, &m_frameSize.y );
152  m_framePos.x = m_framePos.y = 0;
153  m_frameSize.y -= m_msgFrameHeight;
154 
155  m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ),
156  wxSize( m_frameSize.x, m_msgFrameHeight ) );
157 
158  m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
159 
160 #if wxCHECK_VERSION( 3, 1, 3 )
161  Bind( wxEVT_DPI_CHANGED,
162  [&]( wxDPIChangedEvent& )
163  {
164  wxMoveEvent dummy;
165  OnMove( dummy );
166  } );
167 #endif
168 }
169 
170 
172 {
173  delete m_socketServer;
174 
175  for( auto socket : m_sockets )
176  {
177  socket->Shutdown();
178  socket->Destroy();
179  }
180 
182 
183  delete m_actions;
184  delete m_toolManager;
185  delete m_toolDispatcher;
186  delete m_canvas;
187 
188  delete m_currentScreen;
189  m_currentScreen = nullptr;
190 
191  delete m_findReplaceData;
192 
193  m_auimgr.UnInit();
194 
195  ReleaseFile();
196 }
197 
198 
200 {
201  m_file_checker = nullptr;
202 }
203 
204 
205 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
206 {
207  m_file_checker = ::LockFile( aFileName );
208 
209  return m_file_checker && !m_file_checker->IsAnotherRunning();
210 }
211 
212 
214 {
215  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
216 
217  wxRect rect = GetScreenRect();
218  wxPoint center = rect.GetPosition() + rect.GetSize() / 2;
219 
220  if( !frame )
221  {
222  frame = Kiway().Player( FRAME_PYTHON, true, Kiway().GetTop() );
223 
224  // If we received an error in the CTOR due to Python-ness, don't crash
225  if( !frame )
226  return;
227 
228  if( !frame->IsVisible() )
229  frame->Show( true );
230 
231  // On Windows, Raise() does not bring the window on screen, when iconized
232  if( frame->IsIconized() )
233  frame->Iconize( false );
234 
235  frame->Raise();
236  frame->SetPosition( center - frame->GetSize() / 2 );
237 
238  return;
239  }
240 
241  frame->Show( !frame->IsVisible() );
242  frame->SetPosition( center - frame->GetSize() / 2 );
243 }
244 
245 
247 {
248  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
249  return frame && frame->IsVisible();
250 }
251 
252 
254 {
255  // Notify all tools the units have changed
256  if( m_toolManager )
258 
259  UpdateStatusBar();
260  UpdateMsgPanel();
261 }
262 
263 
265 {
268 
269  wxCommandEvent e( UNITS_CHANGED );
270  ProcessEventLocally( e );
271 }
272 
273 
274 void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
275 {
276  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
277 
278  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
279  KIGFX::VIEW_CONTROLS* viewControls = GetCanvas()->GetViewControls();
280 
282 
283  viewControls->LoadSettings();
284 
285  m_galDisplayOptions.ReadCommonConfig( *settings, this );
286 }
287 
288 
290 {
291  if( m_messagePanel )
293 }
294 
295 
297 {
298  UpdateStatusBar();
299  DisplayUnitsMsg();
300 
301  if( m_gridSelectBox == nullptr )
302  return;
303 
304  // Update grid values with the current units setting.
305  m_gridSelectBox->Clear();
306  wxArrayString gridsList;
307 
308  GRID_MENU::BuildChoiceList( &gridsList, config(), this );
309 
310  for( const wxString& grid : gridsList )
311  m_gridSelectBox->Append( grid );
312 
313  m_gridSelectBox->Append( wxT( "---" ) );
314  m_gridSelectBox->Append( _( "Edit User Grid..." ) );
315 
316  m_gridSelectBox->SetSelection( config()->m_Window.grid.last_size_idx );
317 }
318 
319 
320 void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
321 {
322  // No need to update the grid select box if it doesn't exist or the grid setting change
323  // was made using the select box.
324  if( m_gridSelectBox == nullptr )
325  return;
326 
327  int idx = config()->m_Window.grid.last_size_idx;
328  idx = std::max( 0, std::min( idx, (int) m_gridSelectBox->GetCount() - 1 ) );
329 
330  if( idx != m_gridSelectBox->GetSelection() )
331  m_gridSelectBox->SetSelection( idx );
332 }
333 
334 
336 {
337  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
338 }
339 
340 
341 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
342 {
343  wxCHECK_RET( m_gridSelectBox, "m_gridSelectBox uninitialized" );
344 
345  int idx = m_gridSelectBox->GetCurrentSelection();
346 
347  if( idx == int( m_gridSelectBox->GetCount() ) - 2 )
348  {
349  // wxWidgets will check the separator, which we don't want.
350  // Re-check the current grid.
351  wxUpdateUIEvent dummy;
353  }
354  else if( idx == int( m_gridSelectBox->GetCount() ) - 1 )
355  {
356  // wxWidgets will check the Grid Settings... entry, which we don't want.
357  // Re-check the current grid.
358  wxUpdateUIEvent dummy;
360 
361  // Give a time-slice to close the menu before opening the dialog.
362  // (Only matters on some versions of GTK.)
363  wxSafeYield();
364 
366  }
367  else
368  {
369  m_toolManager->RunAction( ACTIONS::gridPreset, true, static_cast<intptr_t>( idx ) );
370  }
371 
372  UpdateStatusBar();
373  m_canvas->Refresh();
374 }
375 
376 
377 void EDA_DRAW_FRAME::OnGridSettings( wxCommandEvent& aEvent )
378 {
379  DIALOG_GRID_SETTINGS dlg( this );
380 
381  if( dlg.ShowModal() == wxID_OK )
382  {
383  UpdateStatusBar();
384  GetCanvas()->Refresh();
385  }
386 }
387 
388 
390 {
391  return config()->m_Window.grid.show;
392 }
393 
394 
396 {
397  config()->m_Window.grid.show = aVisible;
398 
399  // Update the display with the new grid
400  if( GetCanvas() )
401  {
402  // Check to ensure these exist, since this function could be called before
403  // the GAL and View have been created
404  if( GetCanvas()->GetGAL() )
405  GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
406 
407  if( GetCanvas()->GetView() )
409 
410  GetCanvas()->Refresh();
411  }
412 }
413 
414 
416 {
417  if( m_zoomSelectBox == nullptr )
418  return;
419 
420  double zoom = m_canvas->GetGAL()->GetZoomFactor();
421 
422  m_zoomSelectBox->Clear();
423  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
424  m_zoomSelectBox->SetSelection( 0 );
425 
426  for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); ++i )
427  {
428  double current = config()->m_Window.zoom_factors[i];
429 
430  m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) );
431 
432  if( zoom == current )
433  m_zoomSelectBox->SetSelection( i + 1 );
434  }
435 }
436 
437 
438 void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
439 {
440  if( m_zoomSelectBox == nullptr || m_zoomSelectBox->GetParent() == nullptr )
441  return;
442 
443  int current = 0; // display Auto if no match found
444 
445  // check for a match within 1%
446  double zoom = GetCanvas()->GetGAL()->GetZoomFactor();
447 
448  for( unsigned i = 0; i < config()->m_Window.zoom_factors.size(); i++ )
449  {
450  if( std::fabs( zoom - config()->m_Window.zoom_factors[i] ) < ( zoom / 100.0 ) )
451  {
452  current = i + 1;
453  break;
454  }
455  }
456 
457  if( current != m_zoomSelectBox->GetSelection() )
458  m_zoomSelectBox->SetSelection( current );
459 }
460 
461 
462 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
463 {
464  wxCHECK_RET( m_zoomSelectBox, "m_zoomSelectBox uninitialized" );
465 
466  int id = m_zoomSelectBox->GetCurrentSelection();
467 
468  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
469  return;
470 
471  m_toolManager->RunAction( ACTIONS::zoomPreset, true, static_cast<intptr_t>( id ) );
472  UpdateStatusBar();
473  m_canvas->Refresh();
474 }
475 
476 
477 void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
478 {
479  // If the window is moved to a different display, the scaling factor may change
480  double oldFactor = m_galDisplayOptions.m_scaleFactor;
482 
483  if( oldFactor != m_galDisplayOptions.m_scaleFactor && m_canvas )
484  {
485  wxSize clientSize = GetClientSize();
486  GetCanvas()->GetGAL()->ResizeScreen( clientSize.x, clientSize.y );
487  GetCanvas()->GetView()->MarkDirty();
488  }
489 
490  aEvent.Skip();
491 }
492 
493 
495 {
496  COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
497  CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
498 
499  aMenu.AddSeparator( 1000 );
500 
501  auto zoomMenu = std::make_shared<ZOOM_MENU>( this );
502  zoomMenu->SetTool( commonTools );
503  aToolMenu.AddSubMenu( zoomMenu );
504 
505  auto gridMenu = std::make_shared<GRID_MENU>( this );
506  gridMenu->SetTool( commonTools );
507  aToolMenu.AddSubMenu( gridMenu );
508 
509  aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
510  aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
511 }
512 
513 
514 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
515 {
516  SetStatusText( msg, 6 );
517 }
518 
519 
521 {
522  wxString line;
523 
524  line.Printf( "grid %s",
525  MessageTextFromValue( GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x,
526  false ) );
527 
528  SetStatusText( line, 4 );
529 }
530 
531 
533 {
534  wxString msg;
535 
536  switch( m_userUnits )
537  {
538  case EDA_UNITS::INCHES: msg = _( "inches" ); break;
539  case EDA_UNITS::MILS: msg = _( "mils" ); break;
540  case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
541  default: msg = _( "Units" ); break;
542  }
543 
544  SetStatusText( msg, 5 );
545 }
546 
547 
548 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
549 {
550  EDA_BASE_FRAME::OnSize( SizeEv );
551 
552  m_frameSize = GetClientSize( );
553 
554  SizeEv.Skip();
555 }
556 
557 
559 {
560  SetStatusText( GetZoomLevelIndicator(), 1 );
561 
562  // Absolute and relative cursor positions are handled by overloading this function and
563  // handling the internal to user units conversion at the appropriate level.
564 
565  // refresh units display
566  DisplayUnitsMsg();
567 }
568 
569 
571 {
572  // returns a human readable value which can be displayed as zoom
573  // level indicator in dialogs.
574  double zoom = m_canvas->GetGAL()->GetZoomFactor();
575  return wxString::Format( wxT( "Z %.2f" ), zoom );
576 }
577 
578 
580 {
582 
583  COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings();
584  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
585 
586  // Read units used in dialogs and toolbars
587  SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
588 
591 
592  m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
593 
594  m_findReplaceData->SetFlags( aCfg->m_FindReplace.flags );
595  m_findReplaceData->SetFindString( aCfg->m_FindReplace.find_string );
596  m_findReplaceData->SetReplaceString( aCfg->m_FindReplace.replace_string );
597 
598  for( auto& s : aCfg->m_FindReplace.find_history )
599  m_findStringHistoryList.Add( s );
600 
601  for( auto& s : aCfg->m_FindReplace.replace_history )
603 }
604 
605 
607 {
609 
610  WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
611 
612  aCfg->m_System.units = static_cast<int>( m_userUnits );
615 
616  m_galDisplayOptions.WriteConfig( *window );
617 
618  aCfg->m_FindReplace.flags = m_findReplaceData->GetFlags();
619  aCfg->m_FindReplace.find_string = m_findReplaceData->GetFindString();
620  aCfg->m_FindReplace.replace_string = m_findReplaceData->GetReplaceString();
621 
622  aCfg->m_FindReplace.find_history.clear();
623  aCfg->m_FindReplace.replace_history.clear();
624 
625  for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
626  {
627  aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
628  }
629 
630  for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
631  {
632  aCfg->m_FindReplace.replace_history.push_back(
633  m_replaceStringHistoryList[ i ].ToStdString() );
634  }
635 
636  // Save the units used in this frame
637  if( m_toolManager )
638  {
639  if( COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>() )
640  {
641  aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
642  aCfg->m_System.last_metric_units = static_cast<int>( cmnTool->GetLastMetricUnits() );
643  }
644  }
645 }
646 
647 
648 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
649  int aPadding )
650 {
651  if( m_messagePanel )
652  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
653 }
654 
655 
657 {
658  if( m_messagePanel )
660 }
661 
662 
663 void EDA_DRAW_FRAME::SetMsgPanel( const std::vector<MSG_PANEL_ITEM>& aList )
664 {
665  if( m_messagePanel )
666  {
668 
669  for( const MSG_PANEL_ITEM& item : aList )
670  m_messagePanel->AppendMessage( item );
671  }
672 }
673 
674 
675 void EDA_DRAW_FRAME::SetMsgPanel( const wxString& aTextUpper, const wxString& aTextLower,
676  int aPadding )
677 {
678  if( m_messagePanel )
679  {
681 
682  m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
683  }
684 }
685 
686 
688 {
689  wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
690 
691  std::vector<MSG_PANEL_ITEM> items;
692  aItem->GetMsgPanelInfo( this, items );
693  SetMsgPanel( items );
694 }
695 
696 
698 {
700 }
701 
702 
704 {
705  GetCanvas()->SetEvtHandlerEnabled( true );
706  GetCanvas()->StartDrawing();
707 }
708 
709 
711 {
712  GetCanvas()->SwitchBackend( aCanvasType );
714 
716 }
717 
718 
720 {
721 #ifdef __WXMAC__
722  // Cairo renderer doesn't handle Retina displays so there's really only one game
723  // in town for Mac
725 #endif
726 
729 
730  if( cfg )
731  canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
732 
733  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
734  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
735  {
736  wxASSERT( false );
738  }
739 
740  // Legacy canvas no longer supported. Switch to Cairo, and on the first instantiation
741  // the user will be prompted to switch to OpenGL
742  if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
744 
745  return canvasType;
746 }
747 
748 
750 {
751  // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
752  // have a fixed type, or do not have a option to set the canvas type (they inherit from
753  // a parent frame)
754  FRAME_T allowed_frames[] =
755  {
756  FRAME_SCH,
758  FRAME_GERBER,
760  };
761 
762  bool allow_save = false;
763 
764  for( unsigned ii = 0; ii < arrayDim( allowed_frames ); ii++ )
765  {
766  if( m_ident == allowed_frames[ii] )
767  {
768  allow_save = true;
769  break;
770  }
771  }
772 
773  if( !allow_save )
774  return false;
775 
776  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
777  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
778  {
779  wxASSERT( false );
780  return false;
781  }
782 
784 
785  if( cfg )
786  cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
787 
788  return false;
789 }
790 
791 
792 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition ) const
793 {
794  const wxPoint& gridOrigin = GetGridOrigin();
795  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
796 
797  double xOffset = fmod( gridOrigin.x, gridSize.x );
798  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
799  double yOffset = fmod( gridOrigin.y, gridSize.y );
800  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
801 
802  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
803 }
804 
805 
806 wxPoint EDA_DRAW_FRAME::GetNearestHalfGridPosition( const wxPoint& aPosition ) const
807 {
808  const wxPoint& gridOrigin = GetGridOrigin();
809  VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
810 
811  double xOffset = fmod( gridOrigin.x, gridSize.x );
812  int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
813  double yOffset = fmod( gridOrigin.y, gridSize.y );
814  int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
815 
816  return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
817 }
818 
819 
820 const BOX2I EDA_DRAW_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
821 {
822  return BOX2I();
823 }
824 
825 
827 {
828  // To be implemented by subclasses.
829 }
830 
831 
832 void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
833 {
835 }
836 
837 
838 // Find the first child dialog.
839 std::vector<wxWindow*> EDA_DRAW_FRAME::findDialogs()
840 {
841  std::vector<wxWindow*> dialogs;
842 
843  for( wxWindow* window : GetChildren() )
844  {
845  if( dynamic_cast<DIALOG_SHIM*>( window ) )
846  dialogs.push_back( window );
847  }
848 
849  return dialogs;
850 }
851 
852 
853 void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos )
854 {
855  bool centerView = false;
856  BOX2D r = GetCanvas()->GetView()->GetViewport();
857 
858  // Center if we're off the current view, or within 10% of its edge
859  r.Inflate( - (int) r.GetWidth() / 10 );
860 
861  if( !r.Contains( aPos ) )
862  centerView = true;
863 
864  std::vector<BOX2D> dialogScreenRects;
865 
866  for( wxWindow* dialog : findDialogs() )
867  {
868  dialogScreenRects.emplace_back( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
869  dialog->GetSize() );
870  }
871 
872  // Center if we're behind an obscuring dialog, or within 10% of its edge
873  for( BOX2D rect : dialogScreenRects )
874  {
875  rect.Inflate( rect.GetWidth() / 10 );
876 
877  if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
878  centerView = true;
879  }
880 
881  if( centerView )
882  {
883  try
884  {
885  GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
886  }
887  catch( const ClipperLib::clipperException& exc )
888  {
889  wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
890  exc.what() );
891  }
892  }
893 
895 }
896 
897 
898 static const wxString productName = wxT( "KiCad E.D.A. " );
899 
900 
901 void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
902  const wxString& aFullSheetName, const wxString& aFileName,
903  const TITLE_BLOCK& aTitleBlock, int aSheetCount,
904  const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
905  const wxString& aSheetLayer, bool aIsFirstPage )
906 {
907  DS_DRAW_ITEM_LIST drawList;
908 
909  drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
910  drawList.SetMilsToIUfactor( aMils2Iu );
911  drawList.SetPageNumber( aPageNumber );
912  drawList.SetSheetCount( aSheetCount );
913  drawList.SetFileName( aFileName );
914  drawList.SetSheetName( aFullSheetName );
915  drawList.SetSheetLayer( aSheetLayer );
916  drawList.SetProject( aProject );
917  drawList.SetIsFirstPage( aIsFirstPage );
918 
919  drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
920 
921  // Draw item list
922  drawList.Print( aSettings );
923 }
924 
925 
927  double aMils2Iu, const wxString &aFilename,
928  const wxString &aSheetLayer )
929 {
931  return;
932 
933  wxDC* DC = aSettings->GetPrintDC();
934  wxPoint origin = DC->GetDeviceOrigin();
935 
936  if( origin.y > 0 )
937  {
938  DC->SetDeviceOrigin( 0, 0 );
939  DC->SetAxisOrientation( true, false );
940  }
941 
942  ::PrintDrawingSheet( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
943  aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(),
944  aSheetLayer, aScreen->GetVirtualPageNumber() == 1 );
945 
946  if( origin.y > 0 )
947  {
948  DC->SetDeviceOrigin( origin.x, origin.y );
949  DC->SetAxisOrientation( true, true );
950  }
951 }
952 
953 
955 {
956  // Virtual function. Base class implementation returns an empty string.
957  return wxEmptyString;
958 }
959 
960 
961 bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
962  const wxString& wildcard, const wxString& ext,
963  bool isDirectory, bool aIsGlobal,
964  const wxString& aGlobalPath )
965 {
966  wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
967  aFilename.SetExt( ext );
968 
969  wxString dir = aGlobalPath;
970 
971 
972  if( isDirectory && doOpen )
973  {
974  if( !aIsGlobal )
975  {
976  dir = Prj().GetProjectPath();
977  }
978 
979  wxDirDialog dlg( this, prompt, dir,
980  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
981 
982  if( dlg.ShowModal() == wxID_CANCEL )
983  return false;
984 
985  aFilename = dlg.GetPath();
986  aFilename.SetExt( ext );
987  }
988  else
989  {
990  // Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
991  if( aFilename.GetName().empty() )
992  aFilename.SetName( "Library" );
993 
994  if( !aIsGlobal )
995  {
996  dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath();
997  }
998 
999  wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(),
1000  wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
1001  : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
1002 
1003  if( dlg.ShowModal() == wxID_CANCEL )
1004  return false;
1005 
1006  aFilename = dlg.GetPath();
1007  aFilename.SetExt( ext );
1008  }
1009 
1010  return true;
1011 }
1012 
1013 
1015 {
1016  // Rebuild all toolbars, and update the checked state of check tools
1017  if( m_mainToolBar )
1018  ReCreateHToolbar();
1019 
1020  if( m_drawToolBar ) // Drawing tools (typically on right edge of window)
1021  ReCreateVToolbar();
1022 
1023  if( m_optionsToolBar ) // Options (typically on left edge of window)
1025 
1026  if( m_auxiliaryToolBar ) // Additional tools under main toolbar
1028 }
1029 
1030 
1032 {
1033  if( !m_colorSettings )
1034  {
1035  COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings();
1036 
1037  const_cast<EDA_DRAW_FRAME*>( this )->m_colorSettings = colorSettings;
1038  }
1039 
1040  return m_colorSettings;
1041 }
1042 
1043 
1045 {
1047 
1048  if( cmnTool )
1049  {
1050  // Tell the tool what the units used last session
1051  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_imperial_units ) );
1052  cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_metric_units ) );
1053  }
1054 
1055  // Tell the tool what units the frame is currently using
1056  switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
1057  {
1058  default:
1062  }
1063 }
1064 
1065 
1066 void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondaryUnits )
1067 {
1069 
1070  aPrimaryUnit = GetUserUnits();
1071  aSecondaryUnits = EDA_UNITS::MILS;
1072 
1073  if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1074  {
1075  if( cmnTool )
1076  aSecondaryUnits = cmnTool->GetLastMetricUnits();
1077  else
1078  aSecondaryUnits = EDA_UNITS::MILLIMETRES;
1079  }
1080  else
1081  {
1082  if( cmnTool )
1083  aSecondaryUnits = cmnTool->GetLastImperialUnits();
1084  else
1085  aSecondaryUnits = EDA_UNITS::MILS;
1086  }
1087 }
1088 
1089 
1091 {
1093 
1094  // Nudge user to switch to OpenGL if they are on legacy or Cairo
1095  if( m_firstRunDialogSetting < 1 )
1096  {
1098  {
1099  wxString msg =
1100  _( "KiCad can use your graphics card to give you a smoother "
1101  "and faster experience. This option is turned off by "
1102  "default since it is not compatible with all computers.\n\n"
1103  "Would you like to try enabling graphics acceleration?\n\n"
1104  "If you'd like to choose later, select Accelerated Graphics "
1105  "in the Preferences menu." );
1106 
1107  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
1108 
1109  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
1110 
1111  if( dlg.ShowModal() == wxID_YES )
1112  {
1113  // Save Cairo as default in case OpenGL crashes
1115 
1116  // Switch to OpenGL, which will save the new setting if successful
1118 
1119  // Switch back to Cairo if OpenGL is not supported
1120  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
1122 
1123  HardRedraw();
1124  }
1125  else
1126  {
1127  // If they were on legacy, switch to Cairo
1129  HardRedraw();
1130  }
1131  }
1132 
1134  SaveSettings( config() );
1135  }
1136 }
1137 
1138 
1139 void EDA_DRAW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1140 {
1141  // Force a refresh of the message panel to ensure that the text is the right color
1142  // when the window activates
1143  if( !IsIconized() )
1144  m_messagePanel->Refresh();
1145 }
1146 
1147 
1148 void EDA_DRAW_FRAME::onActivate( wxActivateEvent& aEvent )
1149 {
1150  handleActivateEvent( aEvent );
1151 
1152  aEvent.Skip();
1153 }
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:510
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
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
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.
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:383
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: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: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 ...
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:576
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)
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
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.
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.
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: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()
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.
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: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
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
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.