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 <trigo.h>
26 #include <base_units.h>
27 #include <gbr_layer_box_selector.h>
28 #include <msgpanel.h>
29 #include <bitmaps.h>
31 #include <gerbview.h>
32 #include <gerbview_frame.h>
33 #include <gerbview_id.h>
34 #include <gerber_file_image.h>
35 #include <gerber_file_image_list.h>
36 #include <DCodeSelectionbox.h>
37 #include <gerbview_layer_widget.h>
40 #include <tool/tool_manager.h>
41 #include <tool/action_toolbar.h>
42 #include <tool/tool_dispatcher.h>
43 #include <tool/common_control.h>
44 #include <tool/common_tools.h>
45 #include <tool/zoom_tool.h>
46 #include <tools/gerbview_actions.h>
48 #include <tools/gerbview_control.h>
49 #include <view/view.h>
50 #include <gerbview_painter.h>
52 
53 
54 // Config keywords
55 static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
56 static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
57 static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
58 static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
59 
60 // Colors for layers and items
62 
63 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
64  EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
65  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ),
69 {
71  m_gerberLayout = NULL;
72  m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
73  // when the screen shows a 1:1 image
74  // obviously depends on the monitor,
75  // but this is an acceptable value
76 
78 
79  m_showBorderAndTitleBlock = false; // true for reference drawings.
80  m_SelLayerBox = NULL;
81  m_DCodeSelector = NULL;
82  m_SelComponentBox = nullptr;
83  m_SelNetnameBox = nullptr;
84  m_SelAperAttributesBox = nullptr;
85  m_displayMode = 0;
86  m_AboutTitle = "GerbView";
87 
88  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
89  // some methods in code and avoid link errors
90 
91  int fileHistorySize;
92  Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize,
94  m_drillFileHistory.SetMaxFiles( fileHistorySize );
95  m_zipFileHistory.SetMaxFiles( fileHistorySize );
96  m_jobFileHistory.SetMaxFiles( fileHistorySize );
97 
98  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
101 
102  SetCanvas( galCanvas );
103 
104  // GerbView requires draw priority for rendering negative objects
105  galCanvas->GetView()->UseDrawPriority( true );
106 
107  // Give an icon
108  wxIcon icon;
109  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
110  SetIcon( icon );
111 
112  // Be sure a page info is set. this default value will be overwritten later.
113  PAGE_INFO pageInfo( wxT( "GERBER" ) );
114  SetLayout( new GBR_LAYOUT() );
115  SetPageSettings( pageInfo );
116 
117  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
118 
119  SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
120 
121  // Create the PCB_LAYER_WIDGET *after* SetLayout():
123 
124  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
125  // initialize parameters in m_LayersManager
126  LoadSettings( config() );
127 
128  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
129 
130  if( m_LastGridSizeId < 0 )
131  m_LastGridSizeId = 0;
132 
135 
136  setupTools();
137  ReCreateMenuBar();
141 
142  m_auimgr.SetManagedWindow( this );
143 
144  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
145  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
146  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
147 
148  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
149  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
150  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
151  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
152 
153  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
154 
155  ReFillLayerWidget(); // this is near end because contents establish size
156  m_auimgr.Update();
157 
158  SetActiveLayer( 0, true );
160 
162 
163  // Nudge user to switch to OpenGL if they are on legacy or Cairo
164  if( m_firstRunDialogSetting < 1 )
165  {
166  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
167  {
168  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
169  "and faster experience. This option is turned off by "
170  "default since it is not compatible with all computers.\n\n"
171  "Would you like to try enabling graphics acceleration?\n\n"
172  "If you'd like to choose later, select Accelerated Graphics "
173  "in the Preferences menu." );
174 
175  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
176 
177  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
178 
179  if( dlg.ShowModal() == wxID_YES )
180  {
181  // Save Cairo as default in case OpenGL crashes
183 
184  // Switch to OpenGL, which will save the new setting if successful
186 
187  // Switch back to Cairo if OpenGL is not supported
188  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
190  }
191  else
192  {
193  // If they were on legacy, switch to Cairo
195  }
196  }
197 
199  SaveSettings( config() );
200  }
201 
202  SwitchCanvas( canvasType );
203 
204  // Enable the axes to match legacy draw style
205  auto& galOptions = GetGalDisplayOptions();
206  galOptions.m_axesEnabled = true;
207  galOptions.NotifyChanged();
208 
210  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
211 
214 
215  if( GetCanvas() )
217 
218  // Update the checked state of tools
219  SyncToolbars();
220 }
221 
222 
224 {
225  GetCanvas()->GetView()->Clear();
226 
228  delete m_gerberLayout;
229 
230  // Since the file menu contains file history menus, we must ensure that the menu
231  // destructor is called before the file history objects are deleted since their destructor
232  // unregisters the menu from the history.
233  wxMenu* fileMenu = GetMenuBar()->Remove( 0 );
234  delete fileMenu;
235 }
236 
237 
238 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
239 {
240  GetCanvas()->StopDrawing();
241  GetCanvas()->GetView()->Clear();
242 
243  if( m_toolManager )
245 
246  // Be sure any OpenGL event cannot be fired after frame deletion:
247  GetCanvas()->SetEvtHandlerEnabled( false );
248 
249  Destroy();
250 }
251 
252 
253 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
254 {
255  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
256  // when trying to change the view if it is not fully initialized.
257  // It happens when starting Gerbview with a gerber job file to load
258  if( !IsShown() )
259  Show();
260 
261  // The current project path is also a valid command parameter. Check if a single path
262  // rather than a file name was passed to GerbView and use it as the initial MRU path.
263  if( aFileSet.size() > 0 )
264  {
265  wxString path = aFileSet[0];
266 
267  // For some reason wxApp appears to leave the trailing double quote on quoted
268  // parameters which are required for paths with spaces. Maybe this should be
269  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
270  // We can't buy a break!
271  if( path.Last() == wxChar( '\"' ) )
272  path.RemoveLast();
273 
274  if( !wxFileExists( path ) && wxDirExists( path ) )
275  {
276  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
277  m_mruPath = path;
278  return true;
279  }
280 
281  const unsigned limit = std::min( unsigned( aFileSet.size() ),
282  unsigned( GERBER_DRAWLAYERS_COUNT ) );
283 
284  int layer = 0;
285 
286  for( unsigned i = 0; i < limit; ++i, ++layer )
287  {
288  SetActiveLayer( layer );
289 
290  // Try to guess the type of file by its ext
291  // if it is .drl (Kicad files), .nc or .xnc it is a drill file
292  wxFileName fn( aFileSet[i] );
293  wxString ext = fn.GetExt();
294 
295  if( ext == DrillFileExtension || // our Excellon format
296  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
297  LoadExcellonFiles( aFileSet[i] );
298  else if( ext == GerberJobFileExtension )
299  LoadGerberJobFile( aFileSet[i] );
300  else
301  LoadGerberFiles( aFileSet[i] );
302  }
303  }
304 
305  Zoom_Automatique( true ); // Zoom fit in frame
306 
307  return true;
308 }
309 
310 
311 void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
312 {
314 
315  // was: wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
317 
318  bool tmp;
319  aCfg->Read( cfgShowBorderAndTitleBlock, &tmp, false );
321 
322  PAGE_INFO pageInfo( wxT( "GERBER" ) );
323  wxString pageType;
324 
325  aCfg->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
326  pageInfo.SetType( pageType );
327  SetPageSettings( pageInfo );
328 
329  aCfg->Read( cfgShowDCodes, &tmp, true );
331  aCfg->Read( cfgShowNegativeObjects, &tmp, false );
333 
334  // because we have more than one file history, we must read this one
335  // using a specific path
336  aCfg->SetPath( wxT( "drl_files" ) );
337  m_drillFileHistory.Load( *aCfg );
338  aCfg->SetPath( wxT( ".." ) );
339 
340  // because we have more than one file history, we must read this one
341  // using a specific path
342  aCfg->SetPath( wxT( "zip_files" ) );
343  m_zipFileHistory.Load( *aCfg );
344  aCfg->SetPath( wxT( ".." ) );
345 
346  // because we have more than one file history, we must read this one
347  // using a specific path
348  aCfg->SetPath( "job_files" );
349  m_jobFileHistory.Load( *aCfg );
350  aCfg->SetPath( wxT( ".." ) );
351 }
352 
353 
354 void GERBVIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
355 {
357 
358  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
360 
361  aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
363  aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
365 
366  // Save the drill file history list.
367  // Because we have more than one file history, we must save this one
368  // in a specific path
369  aCfg->SetPath( wxT( "drl_files" ) );
370  m_drillFileHistory.Save( *aCfg );
371  aCfg->SetPath( wxT( ".." ) );
372 
373  // Save the zip file history list.
374  aCfg->SetPath( wxT( "zip_files" ) );
375  m_zipFileHistory.Save( *aCfg );
376  aCfg->SetPath( wxT( ".." ) );
377 
378  // Save the job file history list.
379  aCfg->SetPath( "job_files" );
380  m_jobFileHistory.Save( *aCfg );
381  aCfg->SetPath( ".." );
382 }
383 
384 
386 {
390  // Update the checked state of tools
391  SyncToolbars();
392 
393  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
394  wxSize bestz = m_LayersManager->GetBestSize();
395  bestz.x += 5; // gives a little margin
396 
397  lyrs.MinSize( bestz );
398  lyrs.BestSize( bestz );
399  lyrs.FloatingSize( bestz );
400 
401  if( lyrs.IsDocked() )
402  m_auimgr.Update();
403  else
404  m_LayersManager->SetSize( bestz );
405 
406  syncLayerWidget();
407 }
408 
409 
410 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
411 {
412  bool dcodes_changed = false;
413 
414  switch( aLayerID )
415  {
416  case LAYER_DCODES:
417  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
418  m_DisplayOptions.m_DisplayDCodes = aNewState;
419  break;
420 
422  {
424 
425  auto view = GetCanvas()->GetView();
426 
428  {
429  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
430 
431  // GetLayerPolarity() returns true for negative items
432  return ( item && item->GetLayerPolarity() );
433  } );
434  break;
435  }
436 
437  case LAYER_WORKSHEET:
438  m_showBorderAndTitleBlock = aNewState;
439  GetCanvas()->GetView()->SetLayerVisible( LAYER_WORKSHEET, aNewState );
440  break;
441 
442  case LAYER_GERBVIEW_GRID:
443  SetGridVisibility( aNewState );
444  break;
445 
446  default:
447  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aLayerID );
448  }
449 
450  if( dcodes_changed )
451  {
452  auto view = GetCanvas()->GetView();
453 
454  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
455  {
456  int layer = GERBER_DRAW_LAYER( i );
457  int dcode_layer = GERBER_DCODE_LAYER( layer );
458  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
459  }
460  }
461 
463  m_LayersManager->SetRenderState( aLayerID, aNewState );
464 }
465 
466 
468 {
469  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
470  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
472 
474 
476 }
477 
478 
480 {
481  int layer = aLayer;
482 
483  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
484  {
485  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
486 
487  if( gerber == NULL ) // this graphic layer is available: use it
488  return layer;
489 
490  ++layer; // try next graphic layer
491 
492  if( layer >= (int)ImagesMaxCount() )
493  layer = 0;
494  }
495 
496  return NO_AVAILABLE_LAYERS;
497 }
498 
499 
501 {
503 }
504 
505 
506 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
507 {
508  if( aRebuildLayerBox )
510 
511  m_SelLayerBox->SetSelection( GetActiveLayer() );
512 
513  int dcodeSelected = -1;
515 
516  if( gerber )
517  dcodeSelected = gerber->m_Selected_Tool;
518 
519  if( m_DCodeSelector )
520  {
522  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
523  m_DCodeSelector->Enable( gerber != NULL );
524  }
525 }
526 
527 
529 {
530  int ii, jj;
531  wxString Line;
532  wxArrayString list;
533  double scale = GetUserUnits() == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
534  int curr_layer = GetActiveLayer();
535 
536  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
537  {
538  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
539 
540  if( gerber == NULL )
541  continue;
542 
543  if( gerber->GetDcodesCount() == 0 )
544  continue;
545 
546  if( layer == curr_layer )
547  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
548  else
549  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
550 
551  list.Add( Line );
552 
553  const char* units = GetUserUnits() == INCHES ? "\"" : "mm";
554 
555  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
556  {
557  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
558 
559  if( pt_D_code == NULL )
560  continue;
561 
562  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
563  continue;
564 
565  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
566  jj,
567  pt_D_code->m_Num_Dcode,
568  pt_D_code->m_Size.y / scale, units,
569  pt_D_code->m_Size.x / scale, units,
570  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
571  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
572  );
573 
574  if( !pt_D_code->m_Defined )
575  Line += wxT( " (not defined)" );
576 
577  if( pt_D_code->m_InUse )
578  Line += wxT( " (in use)" );
579 
580  list.Add( Line );
581  jj++;
582  }
583  }
584 
585  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
586  wxCHOICEDLG_STYLE & ~wxCANCEL );
587 
588  dlg.ShowModal();
589 }
590 
591 
593 {
594  auto remapping = GetImagesList()->SortImagesByZOrder();
595 
597  syncLayerBox( true );
598 
599  std::unordered_map<int, int> view_remapping;
600 
601  for( auto it : remapping )
602  {
603  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
604  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
605  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
606  }
607 
608  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
609  GetCanvas()->Refresh();
610 }
611 
612 
614 {
615  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
616  aOptions.m_DisplayFlashedItemsFill );
617  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
618  aOptions.m_DisplayLinesFill );
619  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
620  aOptions.m_DisplayPolygonsFill );
621 
622  m_DisplayOptions = aOptions;
623 
625 
626  auto view = GetCanvas()->GetView();
627 
628  if( update_flashed )
629  {
631  {
632  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
633 
634  switch( item->m_Shape )
635  {
636  case GBR_SPOT_CIRCLE:
637  case GBR_SPOT_RECT:
638  case GBR_SPOT_OVAL:
639  case GBR_SPOT_POLY:
640  case GBR_SPOT_MACRO:
641  return true;
642 
643  default:
644  return false;
645  }
646  } );
647  }
648  else if( update_lines )
649  {
650  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
651  {
652  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
653 
654  switch( item->m_Shape )
655  {
656  case GBR_CIRCLE:
657  case GBR_ARC:
658  case GBR_SEGMENT:
659  return true;
660 
661  default:
662  return false;
663  }
664  } );
665  }
666  else if( update_polygons )
667  {
668  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
669  {
670  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
671 
672  return ( item->m_Shape == GBR_POLYGON );
673  } );
674  }
675 
676  view->UpdateAllItems( KIGFX::COLOR );
677  GetCanvas()->Refresh();
678 }
679 
680 
682 {
684 
685  // Display the gerber filename
686  if( gerber == NULL )
687  {
688  SetTitle( "GerbView" );
689 
690  SetStatusText( wxEmptyString, 0 );
691 
692  wxString info;
693  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
694  m_TextInfo->SetValue( info );
695 
696  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
697  m_auimgr.Update();
698 
699  ClearMsgPanel();
700  return;
701  }
702  else
703  {
704  wxString title;
705  title.Printf( _( "GerbView" ) + wxT( " \u2014 %s%s" ),
706  gerber->m_FileName,
707  gerber->m_IsX2_file ? _( " (with X2 attributes)" )
708  : wxString( wxEmptyString ) );
709  SetTitle( title );
710 
711  gerber->DisplayImageInfo( this );
712 
713  // Display Image Name and Layer Name (from the current gerber data):
714  wxString status;
715  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
716  gerber->m_ImageName,
717  gerber->GetLayerParams().m_LayerName );
718  SetStatusText( status, 0 );
719 
720  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
721  wxString info;
722  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
723  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
724  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
725  gerber->m_FmtScale.x,
726  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
727  gerber->m_FmtScale.y,
728  gerber->m_NoTrailingZeros ? 'T' : 'L' );
729 
730  if( gerber->m_IsX2_file )
731  info << wxT(" ") << _( "X2 attr" );
732 
733  m_TextInfo->SetValue( info );
734 
735  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
736  m_auimgr.Update();
737  }
738 }
739 
740 
741 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
742 {
743  switch( aLayerID )
744  {
747  case LAYER_GERBVIEW_GRID: return IsGridVisible();
749  case LAYER_PCB_BACKGROUND: return true;
750 
751  default:
752  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aLayerID );
753  }
754 
755  return true;
756 }
757 
758 
760 {
761  LSET visible = LSET::AllLayersMask();
762 
763  if( GetCanvas() )
764  {
765  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
766  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
767  }
768 
769  return visible;
770 }
771 
772 
774 {
775  if( GetCanvas() )
776  {
777  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
778  {
779  bool v = aLayerMask[i];
780  int layer = GERBER_DRAW_LAYER( i );
781  GetCanvas()->GetView()->SetLayerVisible( layer, v );
784  }
785  }
786 }
787 
788 
789 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
790 {
791  return m_LayersManager->IsLayerVisible( aLayer );
792 }
793 
794 
796 {
797  COLOR4D color = COLOR4D::UNSPECIFIED;
798 
799  switch( aLayerID )
800  {
802  case LAYER_DCODES:
803  case LAYER_WORKSHEET:
805  color = m_colorsSettings->GetItemColor( aLayerID );
806  break;
807 
808  case LAYER_GERBVIEW_GRID:
809  color = GetGridColor();
810  break;
811 
812  default:
813  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ), aLayerID );
814  }
815 
816  return color;
817 }
818 
819 
821 {
824 }
825 
826 
828 {
829  switch( aLayerID )
830  {
832  case LAYER_DCODES:
833  case LAYER_WORKSHEET:
834  m_colorsSettings->SetItemColor( aLayerID, aColor );
835  break;
836 
837  case LAYER_GERBVIEW_GRID:
838  SetGridColor( aColor );
839  m_colorsSettings->SetItemColor( aLayerID, aColor );
840  break;
841 
843  SetDrawBgColor( aColor );
844  m_colorsSettings->SetItemColor( aLayerID, aColor );
845  break;
846 
847  default:
848  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ), aLayerID );
849  }
850 }
851 
852 
854 {
857  else
858  return GetDrawBgColor();
859 }
860 
861 
863 {
864  return m_colorsSettings->GetLayerColor( aLayer );
865 }
866 
867 
868 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
869 {
870  m_colorsSettings->SetLayerColor( aLayer, aColor );
872 }
873 
874 
876 {
877  return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
878 }
879 
880 
881 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
882 {
883  ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
884 
885  if( doLayerWidgetUpdate )
887 
889 
890  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
891  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
892 
894  GetCanvas()->Refresh();
895 }
896 
897 
898 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
899 {
900  m_paper = aPageSettings;
901  GBR_SCREEN* screen = static_cast<GBR_SCREEN*>( GetScreen() );
902 
903  if( screen )
904  screen->InitDataPoints( aPageSettings.GetSizeIU() );
905 
906  auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
907 
908  // Prepare worksheet template
909  auto worksheet =
911 
912  if( screen != NULL )
913  {
914  worksheet->SetSheetNumber( 1 );
915  worksheet->SetSheetCount( 1 );
916  }
917 
918  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
919  drawPanel->SetWorksheet( worksheet );
920 }
921 
922 
924 {
925  return m_paper;
926 }
927 
928 
929 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
930 {
931  // this function is only needed because EDA_DRAW_FRAME is not compiled
932  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
933  // into an application specific source file.
934  return GetPageSettings().GetSizeIU();
935 }
936 
937 
939 {
940  wxASSERT( m_gerberLayout );
941  return m_gerberLayout->GetTitleBlock();
942 }
943 
944 
945 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
946 {
947  wxASSERT( m_gerberLayout );
948  m_gerberLayout->SetTitleBlock( aTitleBlock );
949 }
950 
951 
952 const wxPoint& GERBVIEW_FRAME::GetAuxOrigin() const
953 {
954  wxASSERT( m_gerberLayout );
955  return m_gerberLayout->GetAuxOrigin();
956 }
957 
958 
959 void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
960 {
961  wxASSERT( m_gerberLayout );
962  m_gerberLayout->SetAuxOrigin( aPosition );
963 }
964 
965 
967 {
968  GetCanvas()->GetGAL()->SetGridColor( aColor );
969  m_gridColor = aColor;
970 }
971 
972 
973 /*
974  * Display the grid status.
975  */
977 {
978  wxString line;
979  wxString gridformatter;
980 
981  switch( m_userUnits )
982  {
983  case INCHES:
984  gridformatter = "grid X %.6f Y %.6f";
985  break;
986 
987  case MILLIMETRES:
988  gridformatter = "grid X %.6f Y %.6f";
989  break;
990 
991  default:
992  gridformatter = "grid X %f Y %f";
993  break;
994  }
995 
996  BASE_SCREEN* screen = GetScreen();
997  wxArrayString gridsList;
998 
999  int icurr = screen->BuildGridsChoiceList( gridsList, m_userUnits != INCHES );
1000  GRID_TYPE& grid = screen->GetGrid( icurr );
1001  double grid_x = To_User_Unit( m_userUnits, grid.m_Size.x );
1002  double grid_y = To_User_Unit( m_userUnits, grid.m_Size.y );
1003  line.Printf( gridformatter, grid_x, grid_y );
1004 
1005  SetStatusText( line, 4 );
1006 }
1007 
1008 
1010 {
1012 
1013  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
1014 
1015  if( !screen )
1016  return;
1017 
1018  wxString line;
1020 
1021  if( GetShowPolarCoords() ) // display relative polar coordinates
1022  {
1023  double dx = cursorPos.x - screen->m_LocalOrigin.x;
1024  double dy = cursorPos.y - screen->m_LocalOrigin.y;
1025  double theta = RAD2DEG( atan2( -dy, dx ) );
1026  double ro = hypot( dx, dy );
1027  wxString formatter;
1028 
1029  switch( GetUserUnits() )
1030  {
1031  case INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
1032  case MILLIMETRES: formatter = wxT( "r %.5f theta %.1f" ); break;
1033  case UNSCALED_UNITS: formatter = wxT( "r %f theta %f" ); break;
1034  default: wxASSERT( false ); break;
1035  }
1036 
1037  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
1038 
1039  SetStatusText( line, 3 );
1040  }
1041 
1042  // Display absolute coordinates:
1043  double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
1044  double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
1045 
1046  wxString absformatter;
1047  wxString relformatter;
1048 
1049  switch( GetUserUnits() )
1050  {
1051  case INCHES:
1052  absformatter = wxT( "X %.6f Y %.6f" );
1053  relformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1054  break;
1055 
1056  case MILLIMETRES:
1057  absformatter = wxT( "X %.5f Y %.5f" );
1058  relformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1059  break;
1060 
1061  case UNSCALED_UNITS:
1062  absformatter = wxT( "X %f Y %f" );
1063  relformatter = wxT( "dx %f dy %f dist %f" );
1064  break;
1065 
1066  default:
1067  wxASSERT( false );
1068  break;
1069  }
1070 
1071  line.Printf( absformatter, dXpos, dYpos );
1072  SetStatusText( line, 2 );
1073 
1074  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
1075  {
1076  // Display relative coordinates:
1077  dXpos = To_User_Unit( GetUserUnits(), cursorPos.x - screen->m_LocalOrigin.x );
1078  dYpos = To_User_Unit( GetUserUnits(), cursorPos.y - screen->m_LocalOrigin.y );
1079 
1080  // We already decided the formatter above
1081  line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1082  SetStatusText( line, 3 );
1083  }
1084 
1085  DisplayGridMsg();
1086 }
1087 
1088 
1090 {
1092 }
1093 
1094 
1096 {
1097  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1098 }
1099 
1100 
1102 {
1104 }
1105 
1106 
1108 {
1109  // Called on units change (see EDA_DRAW_FRAME)
1113 }
1114 
1115 
1117 {
1119 
1120  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1121 
1122  if( m_toolManager )
1123  {
1125  GetCanvas()->GetViewControls(), this );
1127  }
1128 
1130 
1132 
1133  galCanvas->GetView()->RecacheAllItems();
1134  galCanvas->SetEventDispatcher( m_toolDispatcher );
1135  galCanvas->StartDrawing();
1136 
1139 
1141  ReCreateMenuBar();
1142 
1143  // Update the checked state of tools
1144  SyncToolbars();
1145 }
1146 
1147 
1149 {
1150  // Create the manager and dispatcher & route draw panel events to the dispatcher
1153  GetCanvas()->GetViewControls(), this );
1154  m_actions = new GERBVIEW_ACTIONS();
1156 
1157  // Register tools
1164 
1165  // Run the selection tool, it is supposed to be always active
1166  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1167 }
1168 
1169 
1171 {
1172  UpdateStatusBar();
1173  DisplayUnitsMsg();
1174 
1175  if( m_gridSelectBox == NULL )
1176  return;
1177 
1178  // Update grid values with the current units setting.
1179  m_gridSelectBox->Clear();
1180  wxArrayString gridsList;
1181  int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1182 
1183  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
1184  {
1185  GRID_TYPE& grid = GetScreen()->GetGrid( i );
1186  m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
1187  }
1188 
1189  m_gridSelectBox->SetSelection( icurr );
1190 }
1191 
1192 
1194 {
1195  if( m_zoomSelectBox == NULL )
1196  return;
1197 
1198  wxString msg;
1199 
1200  m_zoomSelectBox->Clear();
1201  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
1202  m_zoomSelectBox->SetSelection( 0 );
1203 
1204  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
1205  {
1206  msg = _( "Zoom " );
1207 
1208  double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
1209  wxString value = wxString::Format( wxT( "%.2f" ), level );
1210  msg += value;
1211 
1212  m_zoomSelectBox->Append( msg );
1213 
1214  if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
1215  m_zoomSelectBox->SetSelection( i + 1 );
1216  }
1217 }
1218 
1219 
1220 void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
1221 {
1222  if( m_zoomSelectBox == NULL || m_auxiliaryToolBar == NULL )
1223  return;
1224 
1225  int current = 0; // display Auto if no match found
1226 
1227  // check for a match within 1%
1228  double zoom = GetCanvas()->GetLegacyZoom();
1229 
1230  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
1231  {
1232  if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
1233  {
1234  current = i + 1;
1235  break;
1236  }
1237  }
1238 
1239  if( current != m_zoomSelectBox->GetSelection() )
1240  m_zoomSelectBox->SetSelection( current );
1241 }
1242 
1243 
1244 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
1245 {
1246  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1247 
1248  RecreateToolbars();
1249  Layout();
1250  SendSizeEvent();
1251 }
1252 
Class GBR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
Definition: gbr_layout.h:53
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
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)
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...
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
wxString m_mruPath
void SetItemColor(int aItemIdx, COLOR4D aColor)
Function SetItemColor sets the color for an item which is one of the item indices given in enum GAL_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:1458
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.
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
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
Function GetNegativeItemsColor.
TOOL_DISPATCHER * m_toolDispatcher
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
virtual void SetScreen(BASE_SCREEN *aScreen)
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
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
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
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
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...
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
double RAD2DEG(double rad)
Definition: trigo.h:211
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
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...
ACTIONS * m_actions
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)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of ckeck tools.
void SetAuxOrigin(const wxPoint &aPosition)
Definition: gbr_layout.h:74
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:109
static TOOL_ACTION standardGraphics
Definition: actions.h:155
wxString m_AboutTitle
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:286
virtual wxConfigBase * config()
Returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
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 which is one of the item indices given in enum PCB_L...
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
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.
int GetActiveLayer()
Function SetActiveLayer returns the active layer.
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot,...
Definition: title_block.h:40
wxChoice * m_gridSelectBox
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.
void ActivateGalCanvas() override
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
#define GERBER_DCODE_LAYER(x)
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:63
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
Class TOOL_MANAGER.
Definition: tool_manager.h:50
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...
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
static TOOL_ACTION gridPreset
Definition: actions.h:131
PAGE_INFO m_paper
void ReCreateAuxiliaryToolbar() override
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
#define GERBER_DRAWLAYERS_COUNT
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
#define FIRST_DCODE
Definition: dcode.h:71
#define NO_AVAILABLE_LAYERS
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1111
bool LoadGerberFiles(const wxString &aFileName)
function LoadGerberFiles Load a photoplot (Gerber) file or many files.
Class SHAPE_POLY_SET.
EDA_MSG_PANEL * m_messagePanel
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
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
Definition: common.h:134
wxChoice * m_zoomSelectBox
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:73
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:76
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:93
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
wxRealPoint m_Size
Definition: base_screen.h:47
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:274
HOLDER_TYPE GetType()
Definition: kiway_holder.h:49
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:713
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:399
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:706
Class GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be t...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
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.
Class COMMON_CONTROL.
virtual COLOR4D GetGridColor()
virtual void ClearMsgPanel()
Clear all messages from the message panel.
#define GERBVIEW_FRAME_NAME
Class GERBVIEW_FRAME is the main window used in GerbView.
#define _(s)
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:194
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
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)
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
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id.
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:42
Class GERBVIEW_SELECTION_TOOL.
double m_zoomLevelCoeff
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:101
see class PGM_BASE
EDA_UNITS_T m_userUnits
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
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
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:43
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define DEFAULT_FILE_HISTORY_SIZE
IDs range for menuitems file history: The default range file history size is 9 (compatible with defau...
Definition: id.h:69
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
size_t i
Definition: json11.cpp:649
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:324
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:154
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:44
#define IU_PER_MILS
Definition: plotter.cpp:136
void DisplayGridMsg()
Function DisplayGridMsg()
void SetLayerColor(int aLayer, COLOR4D aColor)
Function SetLayerColor changes a layer color for any valid layer.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
virtual void SetGridColor(COLOR4D aColor) override
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
void syncLayerWidget()
Function syncLayerWidget updates the currently "selected" layer within the GERBER_LAYER_WIDGET.
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 CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual COLOR4D GetDrawBgColor() const
virtual void SetGridVisibility(bool aVisible)
TOOL_MANAGER * m_toolManager
void UpdateStatusBar() override
Update the status bar information.
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.
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Recreates the menu bar.
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 m_CmdId
Definition: base_screen.h:46
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...
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:83
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.
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.
void SetElementVisibility(int aLayerID, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
void CommonSettingsChanged(bool aEnvVarsChanged) override
Called after the preferences dialog is run.
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
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static const wxString cfgShowPageSizeOption(wxT("PageSizeOpt"))
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:138
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:114
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
Class PCBNEW_CONTROL.
#define min(a, b)
Definition: auxiliary.h:85
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:77
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
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar.