KiCad PCB EDA Suite
gerbview_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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <fctsys.h>
22 #include <kiface_i.h>
23 #include <pgm_base.h>
24 #include <eda_base_frame.h>
25 #include <class_drawpanel.h>
26 #include <build_version.h>
27 #include <trigo.h>
28 #include <base_units.h>
29 #include <gbr_layer_box_selector.h>
30 #include <msgpanel.h>
31 #include <bitmaps.h>
33 #include <eda_dockart.h>
34 
35 #include <gerbview.h>
36 #include <gerbview_frame.h>
37 #include <gerbview_id.h>
38 #include <hotkeys.h>
39 #include <gerber_file_image.h>
40 #include <gerber_file_image_list.h>
41 #include <dialog_helpers.h>
42 #include <DCodeSelectionbox.h>
43 #include <gerbview_layer_widget.h>
44 
47 #include <tool/tool_manager.h>
48 #include <tool/tool_dispatcher.h>
49 #include <tool/common_tools.h>
50 #include <tool/zoom_tool.h>
51 #include <tools/gerbview_actions.h>
53 #include <tools/gerbview_control.h>
54 #include <view/view.h>
55 #include <gerbview_painter.h>
56 
57 
58 // Config keywords
59 static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
60 static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
61 static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
62 static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
63 
64 // Colors for layers and items
66 
67 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
68  EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
69  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ),
73 {
75  m_gerberLayout = NULL;
76  m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
77  // when the screen shows a 1:1 image
78  // obviously depends on the monitor,
79  // but this is an acceptable value
80 
81  // Be sure a page info is set. this default value will be overwritten later.
82  PAGE_INFO pageInfo( wxT( "GERBER" ) );
83  SetPageSettings( pageInfo );
84 
86 
87  m_showAxis = true; // true to show X and Y axis on screen
88  m_showBorderAndTitleBlock = false; // true for reference drawings.
90  m_SelLayerBox = NULL;
91  m_DCodeSelector = NULL;
92  m_SelComponentBox = nullptr;
93  m_SelNetnameBox = nullptr;
94  m_SelAperAttributesBox = nullptr;
95  m_displayMode = 0;
96  m_AboutTitle = "GerbView";
97 
98  int fileHistorySize;
99  Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize,
101  m_drillFileHistory.SetMaxFiles( fileHistorySize );
102  m_zipFileHistory.SetMaxFiles( fileHistorySize );
103  m_jobFileHistory.SetMaxFiles( fileHistorySize );
104 
105  EDA_DRAW_PANEL_GAL* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
106  m_FrameSize,
109 
110  SetGalCanvas( galCanvas );
111 
112  // GerbView requires draw priority for rendering negative objects
113  galCanvas->GetView()->UseDrawPriority( true );
114 
115  if( m_canvas )
117 
118  // Give an icon
119  wxIcon icon;
120  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
121  SetIcon( icon );
122 
123  SetLayout( new GBR_LAYOUT() );
124 
125  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
126 
127  SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
128 
129  // Create the PCB_LAYER_WIDGET *after* SetLayout():
131 
132  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
133  // initialize parameters in m_LayersManager
134  LoadSettings( config() );
135 
136  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
137 
138  if( m_LastGridSizeId < 0 )
139  m_LastGridSizeId = 0;
140 
143 
145 
146  setupTools();
147  ReCreateMenuBar();
151 
152  m_auimgr.SetManagedWindow( this );
153  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
154 
155  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
156  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
157  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
158 
159  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
160  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
161  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
162  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
163 
164  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
165  m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
166 
167  ReFillLayerWidget(); // this is near end because contents establish size
168  m_auimgr.Update();
169 
170  SetActiveLayer( 0, true );
171  Zoom_Automatique( false ); // Gives a default zoom value
172 
174 
175  // Nudge user to switch to OpenGL if they are on legacy or Cairo
176  if( m_firstRunDialogSetting < 1 )
177  {
178  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
179  {
180  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
181  "and faster experience. This option is turned off by "
182  "default since it is not compatible with all computers.\n\n"
183  "Would you like to try enabling graphics acceleration?\n\n"
184  "If you'd like to choose later, select Modern Toolset "
185  "(Accelerated) in the Preferences menu." );
186 
187  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
188 
189  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
190 
191  if( dlg.ShowModal() == wxID_YES )
192  {
193  // Save Cairo as default in case OpenGL crashes
195 
196  // Switch to OpenGL, which will save the new setting if successful
197  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL );
198  GetEventHandler()->ProcessEvent( evt );
199 
200  // Switch back to Cairo if OpenGL is not supported
201  if( GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
202  {
203  wxCommandEvent cairoEvt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
204  GetEventHandler()->ProcessEvent( cairoEvt );
205  }
206  }
207  else if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
208  {
209  // If they were on legacy, switch them to Cairo
210  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
211  GetEventHandler()->ProcessEvent( evt );
212  }
213  }
214 
216  SaveSettings( config() );
217  }
218  else if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
219  {
220  if( GetGalCanvas()->SwitchBackend( canvasType ) )
221  UseGalCanvas( true );
222 
223  wxUpdateUIEvent e;
225  }
226  else
227  {
229  m_canvas->Refresh();
230  }
231 
232  // Enable the axes to match legacy draw style
233  auto& galOptions = GetGalDisplayOptions();
234  galOptions.m_axesEnabled = true;
235  galOptions.NotifyChanged();
236 
238  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
239 }
240 
241 
243 {
244  GetGalCanvas()->GetView()->Clear();
245 
247  delete m_gerberLayout;
248 }
249 
250 
251 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
252 {
254  GetGalCanvas()->GetView()->Clear();
255 
256  if( m_toolManager )
258 
259  if( IsGalCanvasActive() )
260  {
261  // Be sure any OpenGL event cannot be fired after frame deletion:
262  GetGalCanvas()->SetEvtHandlerEnabled( false );
263  }
264 
265  Destroy();
266 }
267 
268 
269 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
270 {
271  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
272  // when trying to change the view if it is not fully initialized.
273  // It happens when starting Gerbview with a gerber job file to load
274  if( !IsShown() )
275  Show();
276 
277  // The current project path is also a valid command parameter. Check if a single path
278  // rather than a file name was passed to GerbView and use it as the initial MRU path.
279  if( aFileSet.size() > 0 )
280  {
281  wxString path = aFileSet[0];
282 
283  // For some reason wxApp appears to leave the trailing double quote on quoted
284  // parameters which are required for paths with spaces. Maybe this should be
285  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
286  // We can't buy a break!
287  if( path.Last() == wxChar( '\"' ) )
288  path.RemoveLast();
289 
290  if( !wxFileExists( path ) && wxDirExists( path ) )
291  {
292  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
293  m_mruPath = path;
294  return true;
295  }
296 
297  const unsigned limit = std::min( unsigned( aFileSet.size() ),
298  unsigned( GERBER_DRAWLAYERS_COUNT ) );
299 
300  int layer = 0;
301 
302  for( unsigned i = 0; i < limit; ++i, ++layer )
303  {
304  SetActiveLayer( layer );
305 
306  // Try to guess the type of file by its ext
307  // if it is .drl (Kicad files), .nc or .xnc it is a drill file
308  wxFileName fn( aFileSet[i] );
309  wxString ext = fn.GetExt();
310 
311  if( ext == DrillFileExtension || // our Excellon format
312  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
313  LoadExcellonFiles( aFileSet[i] );
314  else if( ext == GerberJobFileExtension )
315  LoadGerberJobFile( aFileSet[i] );
316  else
317  LoadGerberFiles( aFileSet[i] );
318  }
319  }
320 
321  Zoom_Automatique( true ); // Zoom fit in frame
322 
323  return true;
324 }
325 
326 
328 {
330 
331  // Reserve a margin around the bounding box, for a better display.
332  double margin_scale_factor = 1.05;
333 
334  // If there is not item loaded, use the current page size
335  if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
336  {
337  bbox.SetSize( GetPageSizeIU() );
338  bbox.SetOrigin( 0, 0 );
339  }
340 
341  double sizeX = (double) bbox.GetWidth();
342  double sizeY = (double) bbox.GetHeight();
343  wxPoint centre = bbox.Centre();
344 
345  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
346 }
347 
348 
349 void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
350 {
352 
353  // was: wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
355 
357 
358  PAGE_INFO pageInfo( wxT( "GERBER" ) );
359  wxString pageType;
360 
361  aCfg->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
362  pageInfo.SetType( pageType );
363  SetPageSettings( pageInfo );
364 
365  bool tmp;
366  aCfg->Read( cfgShowDCodes, &tmp, true );
368  aCfg->Read( cfgShowNegativeObjects, &tmp, false );
370 
371  // because we have more than one file history, we must read this one
372  // using a specific path
373  aCfg->SetPath( wxT( "drl_files" ) );
374  m_drillFileHistory.Load( *aCfg );
375  aCfg->SetPath( wxT( ".." ) );
376 
377  // because we have more than one file history, we must read this one
378  // using a specific path
379  aCfg->SetPath( wxT( "zip_files" ) );
380  m_zipFileHistory.Load( *aCfg );
381  aCfg->SetPath( wxT( ".." ) );
382 
383  // because we have more than one file history, we must read this one
384  // using a specific path
385  aCfg->SetPath( "job_files" );
386  m_jobFileHistory.Load( *aCfg );
387  aCfg->SetPath( wxT( ".." ) );
388 }
389 
390 
391 void GERBVIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
392 {
394 
395  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
397 
398  aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
400  aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
402 
403  // Save the drill file history list.
404  // Because we have more than one file history, we must save this one
405  // in a specific path
406  aCfg->SetPath( wxT( "drl_files" ) );
407  m_drillFileHistory.Save( *aCfg );
408  aCfg->SetPath( wxT( ".." ) );
409 
410  // Save the zip file history list.
411  aCfg->SetPath( wxT( "zip_files" ) );
412  m_zipFileHistory.Save( *aCfg );
413  aCfg->SetPath( wxT( ".." ) );
414 
415  // Save the job file history list.
416  aCfg->SetPath( "job_files" );
417  m_jobFileHistory.Save( *aCfg );
418  aCfg->SetPath( ".." );
419 }
420 
421 
423 {
427 
428  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
429  wxSize bestz = m_LayersManager->GetBestSize();
430  bestz.x += 5; // gives a little margin
431 
432  lyrs.MinSize( bestz );
433  lyrs.BestSize( bestz );
434  lyrs.FloatingSize( bestz );
435 
436  if( lyrs.IsDocked() )
437  m_auimgr.Update();
438  else
439  m_LayersManager->SetSize( bestz );
440 
441  syncLayerWidget();
442 }
443 
444 
445 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
446 {
447  bool dcodes_changed = false;
448 
449  switch( aLayerID )
450  {
451  case LAYER_DCODES:
452  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
453  m_DisplayOptions.m_DisplayDCodes = aNewState;
454  break;
455 
457  {
459 
460  auto view = GetGalCanvas()->GetView();
461 
463  {
464  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
465 
466  // GetLayerPolarity() returns true for negative items
467  return item->GetLayerPolarity();
468  } );
469  break;
470  }
471 
472  case LAYER_WORKSHEET:
473  m_showBorderAndTitleBlock = aNewState;
474  break;
475 
476  case LAYER_GERBVIEW_GRID:
477  SetGridVisibility( aNewState );
478  break;
479 
480  default:
481  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aLayerID );
482  }
483 
484  if( dcodes_changed )
485  {
486  auto view = GetGalCanvas()->GetView();
487 
488  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
489  {
490  int layer = GERBER_DRAW_LAYER( i );
491  int dcode_layer = GERBER_DCODE_LAYER( layer );
492  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
493  }
494  }
495 
497  m_LayersManager->SetRenderState( aLayerID, aNewState );
498 }
499 
500 
502 {
503  auto view = GetGalCanvas()->GetView();
504  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
505  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
506  settings->LoadDisplayOptions( &m_DisplayOptions );
507 
508  settings->ImportLegacyColors( m_colorsSettings );
509 
510  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
511 }
512 
513 
515 {
516  int layer = aLayer;
517 
518  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
519  {
520  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
521 
522  if( gerber == NULL ) // this graphic layer is available: use it
523  return layer;
524 
525  ++layer; // try next graphic layer
526 
527  if( layer >= (int)ImagesMaxCount() )
528  layer = 0;
529  }
530 
531  return NO_AVAILABLE_LAYERS;
532 }
533 
534 
536 {
538 }
539 
540 
541 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
542 {
543  if( aRebuildLayerBox )
545 
546  m_SelLayerBox->SetSelection( GetActiveLayer() );
547 
548  int dcodeSelected = -1;
550 
551  if( gerber )
552  dcodeSelected = gerber->m_Selected_Tool;
553 
554  if( m_DCodeSelector )
555  {
557  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
558  m_DCodeSelector->Enable( gerber != NULL );
559  }
560 }
561 
562 
564 {
565  int ii, jj;
566  wxString Line;
567  wxArrayString list;
568  double scale = GetUserUnits() == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
569  int curr_layer = GetActiveLayer();
570 
571  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
572  {
573  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
574 
575  if( gerber == NULL )
576  continue;
577 
578  if( gerber->GetDcodesCount() == 0 )
579  continue;
580 
581  if( layer == curr_layer )
582  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
583  else
584  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
585 
586  list.Add( Line );
587 
588  const char* units = GetUserUnits() == INCHES ? "\"" : "mm";
589 
590  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
591  {
592  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
593 
594  if( pt_D_code == NULL )
595  continue;
596 
597  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
598  continue;
599 
600  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
601  jj,
602  pt_D_code->m_Num_Dcode,
603  pt_D_code->m_Size.y / scale, units,
604  pt_D_code->m_Size.x / scale, units,
605  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
606  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
607  );
608 
609  if( !pt_D_code->m_Defined )
610  Line += wxT( " (not defined)" );
611 
612  if( pt_D_code->m_InUse )
613  Line += wxT( " (in use)" );
614 
615  list.Add( Line );
616  jj++;
617  }
618  }
619 
620  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
621  wxCHOICEDLG_STYLE & ~wxCANCEL );
622 
623  dlg.ShowModal();
624 }
625 
626 
628 {
629  auto remapping = GetImagesList()->SortImagesByZOrder();
630 
632  syncLayerBox( true );
633 
634  std::unordered_map<int, int> view_remapping;
635 
636  for( auto it : remapping )
637  {
638  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
639  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
640  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
641  }
642 
643  GetGalCanvas()->GetView()->ReorderLayerData( view_remapping );
644  GetCanvas()->Refresh();
645 }
646 
647 
649 {
650  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
651  aOptions.m_DisplayFlashedItemsFill );
652  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
653  aOptions.m_DisplayLinesFill );
654  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
655  aOptions.m_DisplayPolygonsFill );
656 
657  m_DisplayOptions = aOptions;
658 
660 
661  auto view = GetGalCanvas()->GetView();
662 
663  if( update_flashed )
664  {
666  {
667  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
668 
669  switch( item->m_Shape )
670  {
671  case GBR_SPOT_CIRCLE:
672  case GBR_SPOT_RECT:
673  case GBR_SPOT_OVAL:
674  case GBR_SPOT_POLY:
675  case GBR_SPOT_MACRO:
676  return true;
677 
678  default:
679  return false;
680  }
681  } );
682  }
683  else if( update_lines )
684  {
685  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
686  {
687  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
688 
689  switch( item->m_Shape )
690  {
691  case GBR_CIRCLE:
692  case GBR_ARC:
693  case GBR_SEGMENT:
694  return true;
695 
696  default:
697  return false;
698  }
699  } );
700  }
701  else if( update_polygons )
702  {
703  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
704  {
705  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
706 
707  return ( item->m_Shape == GBR_POLYGON );
708  } );
709  }
710 
711  view->UpdateAllItems( KIGFX::COLOR );
712 
713  m_canvas->Refresh( true );
714 }
715 
716 
718 {
720 
721  // Display the gerber filename
722  if( gerber == NULL )
723  {
724  SetTitle( "GerbView" );
725 
726  SetStatusText( wxEmptyString, 0 );
727 
728  wxString info;
729  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
730  m_TextInfo->SetValue( info );
731 
732  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
733  m_auimgr.Update();
734 
735  ClearMsgPanel();
736  return;
737  }
738  else
739  {
740  wxString title;
741  title.Printf( _( "GerbView" ) + wxT( " \u2014 %s%s" ),
742  gerber->m_FileName,
743  gerber->m_IsX2_file ? _( " (with X2 attributes)" )
744  : wxString( wxEmptyString ) );
745  SetTitle( title );
746 
747  gerber->DisplayImageInfo( this );
748 
749  // Display Image Name and Layer Name (from the current gerber data):
750  wxString status;
751  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
752  gerber->m_ImageName,
753  gerber->GetLayerParams().m_LayerName );
754  SetStatusText( status, 0 );
755 
756  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
757  wxString info;
758  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
759  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
760  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
761  gerber->m_FmtScale.x,
762  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
763  gerber->m_FmtScale.y,
764  gerber->m_NoTrailingZeros ? 'T' : 'L' );
765 
766  if( gerber->m_IsX2_file )
767  info << wxT(" ") << _( "X2 attr" );
768 
769  m_TextInfo->SetValue( info );
770 
771  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
772  m_auimgr.Update();
773  }
774 }
775 
776 
777 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
778 {
779  switch( aLayerID )
780  {
781  case LAYER_DCODES:
783 
786 
787  case LAYER_GERBVIEW_GRID:
788  return IsGridVisible();
789 
790  case LAYER_WORKSHEET:
792 
794  return true;
795 
796  default:
797  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aLayerID );
798  }
799 
800  return true;
801 }
802 
803 
805 {
806  LSET visible = LSET::AllLayersMask();
807 
808  if( auto canvas = GetGalCanvas() )
809  {
810  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
811  visible[i] = canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
812  }
813 
814  return visible;
815 }
816 
817 
819 {
820  if( auto canvas = GetGalCanvas() )
821  {
822  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
823  {
824  bool v = aLayerMask[i];
825  int layer = GERBER_DRAW_LAYER( i );
826  canvas->GetView()->SetLayerVisible( layer, v );
827  canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
829  }
830  }
831 }
832 
833 
834 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
835 {
836  return m_LayersManager->IsLayerVisible( aLayer );
837 }
838 
839 
841 {
842  COLOR4D color = COLOR4D::UNSPECIFIED;
843 
844  switch( aLayerID )
845  {
847  case LAYER_DCODES:
848  case LAYER_WORKSHEET:
850  color = m_colorsSettings->GetItemColor( aLayerID );
851  break;
852 
853  case LAYER_GERBVIEW_GRID:
854  color = GetGridColor();
855  break;
856 
857  default:
858  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ), aLayerID );
859  }
860 
861  return color;
862 }
863 
864 
866 {
869 }
870 
871 
873 {
874  switch( aLayerID )
875  {
877  case LAYER_DCODES:
878  case LAYER_WORKSHEET:
879  m_colorsSettings->SetItemColor( aLayerID, aColor );
880  break;
881 
882  case LAYER_GERBVIEW_GRID:
883  SetGridColor( aColor );
884  m_colorsSettings->SetItemColor( aLayerID, aColor );
885  break;
886 
888  SetDrawBgColor( aColor );
889  m_colorsSettings->SetItemColor( aLayerID, aColor );
890  break;
891 
892  default:
893  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ), aLayerID );
894  }
895 }
896 
897 
899 {
902  else
903  return GetDrawBgColor();
904 }
905 
906 
908 {
909  return m_colorsSettings->GetLayerColor( aLayer );
910 }
911 
912 
913 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
914 {
915  m_colorsSettings->SetLayerColor( aLayer, aColor );
917 }
918 
919 
921 {
922  return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
923 }
924 
925 
926 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
927 {
928  ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
929 
930  if( doLayerWidgetUpdate )
932 
934 
935  if( IsGalCanvasActive() )
936  {
937  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
938  GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
939 
941 
942  GetGalCanvas()->Refresh();
943  }
944 }
945 
946 
947 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
948 {
949  m_paper = aPageSettings;
950  GBR_SCREEN* screen = static_cast<GBR_SCREEN*>( GetScreen() );
951 
952  if( screen )
953  screen->InitDataPoints( aPageSettings.GetSizeIU() );
954 
955  if( IsGalCanvasActive() )
956  {
957  auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetGalCanvas() );
958 
959  // Prepare worksheet template
960  auto worksheet =
962 
963  if( screen != NULL )
964  {
965  worksheet->SetSheetNumber( 1 );
966  worksheet->SetSheetCount( 1 );
967  }
968 
969  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
970  drawPanel->SetWorksheet( worksheet );
971  }
972 }
973 
974 
976 {
977  return m_paper;
978 }
979 
980 
981 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
982 {
983  // this function is only needed because EDA_DRAW_FRAME is not compiled
984  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
985  // into an application specific source file.
986  return GetPageSettings().GetSizeIU();
987 }
988 
989 
991 {
992  wxASSERT( m_gerberLayout );
993  return m_gerberLayout->GetTitleBlock();
994 }
995 
996 
997 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
998 {
999  wxASSERT( m_gerberLayout );
1000  m_gerberLayout->SetTitleBlock( aTitleBlock );
1001 }
1002 
1003 
1004 const wxPoint& GERBVIEW_FRAME::GetAuxOrigin() const
1005 {
1006  wxASSERT( m_gerberLayout );
1007  return m_gerberLayout->GetAuxOrigin();
1008 }
1009 
1010 
1011 void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
1012 {
1013  wxASSERT( m_gerberLayout );
1014  m_gerberLayout->SetAuxOrigin( aPosition );
1015 }
1016 
1017 
1018 void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
1019 {
1020  GetScreen()->SetCurItem( aItem );
1021 
1022  if( aItem )
1023  {
1024  if( aDisplayInfo )
1025  {
1026  MSG_PANEL_ITEMS items;
1027  aItem->GetMsgPanelInfo( m_UserUnits, items );
1028  SetMsgPanel( items );
1029  }
1030  }
1031  else
1032  {
1033  EraseMsgBox();
1034  }
1035 }
1036 
1037 
1039 {
1040  if( IsGalCanvasActive() )
1041  GetGalCanvas()->GetGAL()->SetGridColor( aColor );
1042 
1043  m_gridColor = aColor;
1044 }
1045 
1046 
1048 {
1050 
1051  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
1052 
1053  if( !screen )
1054  return;
1055 
1056  int dx;
1057  int dy;
1058  double dXpos;
1059  double dYpos;
1060  wxString line;
1061 
1062  if( m_DisplayOptions.m_DisplayPolarCood ) // display relative polar coordinates
1063  {
1064  double theta, ro;
1065 
1066  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1067  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1068 
1069  // atan2 in the 0,0 case returns 0
1070  theta = RAD2DEG( atan2( (double) -dy, (double) dx ) );
1071 
1072  ro = hypot( dx, dy );
1073  wxString formatter;
1074  switch( GetUserUnits() )
1075  {
1076  case INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
1077  case MILLIMETRES: formatter = wxT( "r %.5f theta %.1f" ); break;
1078  case UNSCALED_UNITS: formatter = wxT( "r %f theta %f" ); break;
1079  case DEGREES: wxASSERT( false ); break;
1080  }
1081 
1082  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
1083 
1084  SetStatusText( line, 3 );
1085  }
1086 
1087  // Display absolute coordinates:
1090 
1091  wxString absformatter;
1092  wxString relformatter;
1093 
1094  switch( GetUserUnits() )
1095  {
1096  case INCHES:
1097  absformatter = wxT( "X %.6f Y %.6f" );
1098  relformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1099  break;
1100 
1101  case MILLIMETRES:
1102  absformatter = wxT( "X %.5f Y %.5f" );
1103  relformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1104  break;
1105 
1106  case UNSCALED_UNITS:
1107  absformatter = wxT( "X %f Y %f" );
1108  relformatter = wxT( "dx %f dy %f dist %f" );
1109  break;
1110 
1111  case DEGREES:
1112  wxASSERT( false );
1113  break;
1114  }
1115 
1116  line.Printf( absformatter, dXpos, dYpos );
1117  SetStatusText( line, 2 );
1118 
1119  if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates
1120  {
1121  // Display relative coordinates:
1122  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1123  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1124  dXpos = To_User_Unit( GetUserUnits(), dx );
1125  dYpos = To_User_Unit( GetUserUnits(), dy );
1126 
1127  // We already decided the formatter above
1128  line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1129  SetStatusText( line, 3 );
1130  }
1131 }
1132 
1133 
1135 {
1137 }
1138 
1139 
1141 {
1142  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1143 }
1144 
1145 
1147 {
1149 }
1150 
1151 
1153 { // Called on units change (see EDA_DRAW_FRAME)
1157 }
1158 
1159 
1160 void GERBVIEW_FRAME::UseGalCanvas( bool aEnable )
1161 {
1162  EDA_DRAW_FRAME::UseGalCanvas( aEnable );
1163 
1164  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1165 
1166  if( m_toolManager )
1168  GetGalCanvas()->GetViewControls(), this );
1169 
1170  if( aEnable )
1171  {
1172  if( m_toolManager )
1174 
1175  m_colorsSettings->SetLegacyMode( false );
1176 
1178 
1180 
1181  galCanvas->GetView()->RecacheAllItems();
1182  galCanvas->SetEventDispatcher( m_toolDispatcher );
1183  galCanvas->StartDrawing();
1184  }
1185  else
1186  {
1187  if( m_toolManager )
1189 
1190  galCanvas->StopDrawing();
1191 
1192  // Redirect all events to the legacy canvas
1193  galCanvas->SetEventDispatcher( NULL );
1194 
1196  m_canvas->Refresh();
1197  }
1198 
1201 
1203  ReCreateMenuBar();
1204 }
1205 
1206 
1208 {
1209  // Create the manager and dispatcher & route draw panel events to the dispatcher
1212  GetGalCanvas()->GetViewControls(), this );
1213  m_actions = new GERBVIEW_ACTIONS();
1215 
1216  // Register tools
1222 
1223  // Run the selection tool, it is supposed to be always active
1224  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1225 }
1226 
1227 
1229 {
1230  UpdateStatusBar();
1231  DisplayUnitsMsg();
1232 
1233  if( m_gridSelectBox == NULL )
1234  return;
1235 
1236  // Update grid values with the current units setting.
1237  m_gridSelectBox->Clear();
1238  wxArrayString gridsList;
1239  int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1240 
1241  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
1242  {
1243  GRID_TYPE& grid = GetScreen()->GetGrid( i );
1244  m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
1245  }
1246 
1247  m_gridSelectBox->SetSelection( icurr );
1248 }
1249 
1250 
1252 {
1253  if( m_zoomSelectBox == NULL )
1254  return;
1255 
1256  wxString msg;
1257 
1258  m_zoomSelectBox->Clear();
1259  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
1260  m_zoomSelectBox->SetSelection( 0 );
1261 
1262  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
1263  {
1264  msg = _( "Zoom " );
1265 
1266  double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
1267  wxString value = wxString::Format( wxT( "%.2f" ), level );
1268  msg += value;
1269 
1270  m_zoomSelectBox->Append( msg );
1271 
1272  if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
1273  m_zoomSelectBox->SetSelection( i + 1 );
1274  }
1275 }
1276 
1277 
1278 void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
1279 {
1280  if( m_zoomSelectBox == NULL || m_auxiliaryToolBar == NULL )
1281  return;
1282 
1283  int current = 0; // display Auto if no match found
1284 
1285  // check for a match within 1%
1286  double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom();
1287 
1288  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
1289  {
1290  if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
1291  {
1292  current = i + 1;
1293  break;
1294  }
1295  }
1296 
1297  if( current != m_zoomSelectBox->GetSelection() )
1298  m_zoomSelectBox->SetSelection( current );
1299 }
1300 
1301 
1303 {
1305 
1306  ReCreateHToolbar();
1309  Layout();
1310  SendSizeEvent();
1311 }
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:130
Class GBR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
Definition: gbr_layout.h:53
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: base_screen.h:231
wxString m_LayerName
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
void CommonSettingsChanged() override
Notification event that some of the common (suite-wide) settings have changed.
static const wxString cfgShowBorderAndTitleBlock(wxT("ShowBorderAndTitleBlock"))
static TOOL_ACTION layerChanged
void SetVisibleElementColor(int aLayerID, COLOR4D aColor)
void SortLayersByX2Attributes()
virtual void SetHighContrastLayer(int aLayer)
Function SetHighContrastLayer Takes care of display settings for the given layer to be displayed in h...
wxString m_mruPath
Most recently used path.
void SetItemColor(int aItemIdx, COLOR4D aColor)
Function SetItemColor sets the color for an item which is one of the item indices given in enum PCB_L...
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Updates items in the view according to the given flags and condition.
Definition: view.cpp:1457
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
COLORS_DESIGN_SETTINGS g_ColorsSettings(FRAME_GERBER)
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:949
bool m_showAxis
True shows the X and Y axis indicators.
Definition: draw_frame.h:138
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
void UpdateStatusBar() override
Update the status bar information.
void DeleteAllImages()
remove all loaded data in list, and delete all images.
ACTION_TOOLBAR * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window.
Definition: draw_frame.h:159
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
Function GetNegativeItemsColor.
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:131
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
ACTION_TOOLBAR * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:166
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
virtual void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:184
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
void SetAuxOrigin(const wxPoint &aPoint) override
COLOR4D GetVisibleElementColor(int aLayerID)
Function GetVisibleElementColor returns the color of a gerber visible element.
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
void SetCurItem(GERBER_DRAW_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
FILE_HISTORY m_jobFileHistory
void SetPageSettings(const PAGE_INFO &aPageSettings) override
virtual bool IsGridVisible() const
Definition: draw_frame.h:533
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
int color
Definition: DXF_plotter.cpp:62
std::unordered_map< int, int > SortImagesByZOrder()
Sort loaded images by Z order priority, if they have the X2 FileFormat info (SortImagesByZOrder updat...
void UseDrawPriority(bool aFlag)
Function UseDrawPriority()
Definition: view.h:667
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1401
double RAD2DEG(double rad)
Definition: trigo.h:209
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE.
Class GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters ...
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function SetActiveLayer will change the currently active layer to aLayer and also update the GERBER_L...
int GetWidth() const
Definition: eda_rect.h:117
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:117
virtual void SetDrawBgColor(COLOR4D aColor)
Definition: draw_frame.h:391
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void SetAuxOrigin(const wxPoint &aPosition)
Definition: gbr_layout.h:79
void SetDCodeSelection(int aDCodeId)
Function SetDCodeSelection.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_DRAW_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
wxString m_AboutTitle
Name of program displayed in About.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
static const wxString cfgShowNegativeObjects(wxT("ShowNegativeObjectsOpt"))
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:417
virtual wxConfigBase * config()
Return the wxConfigBase used in SaveSettings().
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer.
void SetGalCanvas(EDA_DRAW_PANEL_GAL *aPanel)
Definition: draw_frame.h:932
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
struct EDA_HOTKEY_CONFIG GerbviewHotkeysDescr[]
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
Definition: draw_frame.h:156
static const wxString cfgShowDCodes(wxT("ShowDCodesOpt"))
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Visibility flag has changed.
Definition: view_item.h:56
The base class for create windows for drawing purpose.
Definition: draw_frame.h:82
int GetActiveLayer()
Function SetActiveLayer returns the active layer.
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot,...
Definition: title_block.h:40
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
wxChoice * m_gridSelectBox
Definition: draw_frame.h:153
COLOR4D m_gridColor
Grid color.
Definition: draw_frame.h:117
virtual void UseGalCanvas(bool aEnable)
Use to switch between standard and GAL-based canvas.
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
wxChoice * m_SelNetnameBox
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
void SetGridVisibility(bool aVisible) override
Function SetGridVisibility(), virtual from EDA_DRAW_FRAME It may be overloaded by derived classes.
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
Class GERBVIEW_ACTIONS.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void DisplayUnitsMsg()
Display current unit pane on the status bar.
void ReCreateHToolbar() override
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
FILE_HISTORY m_zipFileHistory
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use.
Definition: draw_frame.h:924
#define GERBER_DCODE_LAYER(x)
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:72
Class TOOL_MANAGER.
Definition: tool_manager.h:49
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
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.
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:104
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
#define DEFAULT_FILE_HISTORY_SIZE
The default file history size is 9.
Definition: pgm_base.h:61
Item is being added to the view.
Definition: view_item.h:60
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Updates the display options and refreshes the view as needed.
Class LSET is a set of PCB_LAYER_IDs.
unsigned ImagesMaxCount() const
The max number of file images.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: common.cpp:130
PAGE_INFO m_paper
void ReCreateAuxiliaryToolbar() override
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:110
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
#define GERBER_DRAWLAYERS_COUNT
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
#define FIRST_DCODE
Definition: dcode.h:71
#define NO_AVAILABLE_LAYERS
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1110
bool LoadGerberFiles(const wxString &aFileName)
function LoadGerberFiles Load a photoplot (Gerber) file or many files.
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:169
GAL not used (the legacy wxDC engine is used)
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
double To_User_Unit(EDA_UNITS_T aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:93
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:148
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
Definition: common.h:158
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:154
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
COLORS_DESIGN_SETTINGS * m_colorsSettings
GBR_DISPLAY_OPTIONS m_DisplayOptions
void applyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
const wxPoint & GetAuxOrigin() const
Definition: gbr_layout.h:74
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:84
Definition of file extensions used in Kicad.
Base window classes and related definitions.
static const wxChar * ShowApertureType(APERTURE_T aType)
Function ShowApertureType returns a character string telling what type of aperture type aType is.
Definition: dcode.cpp:95
double BestZoom() override
Return the zoom level which displays the full page on screen.
Helper dialog and control classes.
bool IsElementVisible(int aLayerID) const
Function IsElementVisible tests whether a given element category is visible.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:53
GBR_LAYOUT * m_gerberLayout
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:713
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:705
bool m_DisplayPolarCood
Option to display coordinates in status bar in X,Y or Polar coords.
virtual void UseGalCanvas(bool aEnable) override
Class GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be t...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
EDA_RECT ComputeBoundingBox() const
Function ComputeBoundingBox calculates the bounding box containing all Gerber items.
Definition: gbr_layout.cpp:56
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:399
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
void OnCloseWindow(wxCloseEvent &Event)
FILE_HISTORY m_drillFileHistory
Class GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
int m_LastGridSizeId
Definition: draw_frame.h:112
virtual COLOR4D GetGridColor()
Definition: draw_frame.h:550
virtual void ClearMsgPanel()
Clear all messages from the message panel.
#define GERBVIEW_FRAME_NAME
Class GERBVIEW_FRAME is the main window used in GerbView.
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:190
Specialization of the wxAuiPaneInfo class for KiCad panels.
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
#define ZOOM_FACTOR(x)
Definition: pcb_screen.cpp:42
int GetHeight() const
Definition: eda_rect.h:118
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Class COMMON_TOOLS.
Definition: common_tools.h:38
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
void ReCreateOptToolbar()
Create or update the left vertical toolbar (option toolbar.
Class TOOL_DISPATCHER.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
Definition: dcode.h:105
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
GBR_LAYOUT * GetGerberLayout() const
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
const PAGE_INFO & GetPageSettings() const override
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:128
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id.
void SetMaxFiles(size_t aMaxFiles)
Definition: pgm_base.cpp:79
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
Class GERBVIEW_SELECTION_TOOL.
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:120
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
wxChoice * m_SelAperAttributesBox
const int scale
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:100
see class PGM_BASE
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
void OnUpdateSwitchCanvas(wxUpdateUIEvent &aEvent)
Update UI called when switches currently used canvas (default / Cairo / OpenGL).
PARAM_CFG_ARRAY & GetConfigurationSettings(void)
Function GetConfigurationSettings Populates the GerbView applications settings list.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:45
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
size_t i
Definition: json11.cpp:597
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:50
#define IU_PER_MILS
Definition: plotter.cpp:134
void SetLayerColor(int aLayer, COLOR4D aColor)
Function SetLayerColor changes a layer color for any valid layer.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
wxPoint Centre() const
Definition: eda_rect.h:60
virtual void SetGridColor(COLOR4D aColor) override
void syncLayerWidget()
Function syncLayerWidget updates the currently "selected" layer within the GERBER_LAYER_WIDGET.
void SetEnableBlockCommands(bool aEnable)
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxChoice * m_SelComponentBox
void SetLegacyMode(bool aMode)
Enables or disables legacy color mode.
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:386
virtual void SetGridVisibility(bool aVisible)
It may be overloaded by derived classes.
Definition: draw_frame.h:542
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
#define GERBER_DRAW_LAYER(x)
void InitTools()
Function InitTools() Initializes all registered tools.
void ReFillRender()
Function ReFillRender Rebuild Render for instance after the config is read.
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Recreates the menu bar.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
int getNextAvailableLayer(int aLayer=0) const
Function getNextAvailableLayer finds the next empty layer starting at aLayer and returns it to the ca...
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
int m_CmdId
Definition: base_screen.h:48
Message panel definition file.
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
void SetLayout(GBR_LAYOUT *aLayout)
Function SetLayout sets the m_gerberLayout member in such as way as to ensure deleting any previous G...
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:125
ACTIONS * m_actions
Definition: draw_frame.h:132
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible tests whether a given layer is visible.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
Rendering engine changes.
Definition: tool_base.h:84
void wxConfigLoadSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes the row selection in the layer list to aLayer provided.
virtual void UpdateStatusBar()
Update the status bar information.
void Liste_D_Codes()
Set Size Items (Lines, Flashes) from DCodes List.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408
void SetElementVisibility(int aLayerID, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading new ...
void UpdateTitleAndInfo()
Function UpdateTitleAndInfo displays the short filename (if exists) of the selected layer on the capt...
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
long m_firstRunDialogSetting
Key to control whether first run dialog is shown on startup.
Definition: draw_frame.h:151
static const wxString cfgShowPageSizeOption(wxT("PageSizeOpt"))
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
const std::string DrillFileExtension
void CommonSettingsChanged() override
Called after the preferences dialog is run.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
Class PCBNEW_CONTROL.
#define min(a, b)
Definition: auxiliary.h:85
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:89
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39