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-2018 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 
25 #include <fctsys.h>
26 #include <kiface_i.h>
27 #include <pgm_base.h>
28 #include <eda_base_frame.h>
29 #include <class_drawpanel.h>
30 #include <build_version.h>
31 #include <trigo.h>
32 #include <base_units.h>
33 #include <gbr_layer_box_selector.h>
34 #include <msgpanel.h>
35 #include <bitmaps.h>
37 
38 #include <gerbview.h>
39 #include <gerbview_frame.h>
40 #include <gerbview_id.h>
41 #include <hotkeys.h>
42 #include <gerber_file_image.h>
43 #include <gerber_file_image_list.h>
44 #include <dialog_helpers.h>
45 #include <DCodeSelectionbox.h>
46 #include <gerbview_layer_widget.h>
47 
50 #include <tool/tool_manager.h>
51 #include <tool/tool_dispatcher.h>
52 #include <tools/gerbview_actions.h>
53 #include <view/view.h>
54 #include <gerbview_painter.h>
55 
56 
57 // Config keywords
58 static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
59 static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
60 static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
61 static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
62 static const wxString IconScaleEntry = "GvIconScale";
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 )
70 {
72  m_gerberLayout = NULL;
73  m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
74  // when the screen shows a 1:1 image
75  // obviously depends on the monitor,
76  // but this is an acceptable value
77 
78  PAGE_INFO pageInfo( wxT( "GERBER" ) );
79  SetPageSettings( pageInfo );
80 
82 
83  m_showAxis = true; // true to show X and Y axis on screen
84  m_showBorderAndTitleBlock = false; // true for reference drawings.
86  m_SelLayerBox = NULL;
87  m_DCodeSelector = NULL;
88  m_SelComponentBox = nullptr;
89  m_SelNetnameBox = nullptr;
90  m_SelAperAttributesBox = nullptr;
91  m_displayMode = 0;
95 
96  EDA_DRAW_PANEL_GAL* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
100 
101  SetGalCanvas( galCanvas );
102 
103  // GerbView requires draw priority for rendering negative objects
104  galCanvas->GetView()->UseDrawPriority( true );
105 
106  if( m_canvas )
108 
109  // Give an icon
110  wxIcon icon;
111  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
112  SetIcon( icon );
113 
114  SetLayout( new GBR_LAYOUT() );
115 
116  SetVisibleLayers( -1 ); // All draw layers visible.
117 
118  SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
119 
120  // Create the PCB_LAYER_WIDGET *after* SetLayout():
121  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
122  int pointSize = font.GetPointSize();
123  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
124 
125  if( screenHeight <= 900 )
126  pointSize = (pointSize * 8) / 10;
127 
128  m_LayersManager = new GERBER_LAYER_WIDGET( this, m_canvas, pointSize );
129 
130  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
131  // initialize parameters in m_LayersManager
132  LoadSettings( config() );
133 
134  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
135 
136  if( m_LastGridSizeId < 0 )
137  m_LastGridSizeId = 0;
138 
141 
142  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
143 
144  m_auimgr.SetManagedWindow( this );
145 
146  ReCreateMenuBar();
150 
151  EDA_PANEINFO horiz;
152  horiz.HorizontalToolbarPane();
153 
154  EDA_PANEINFO vert;
155  vert.VerticalToolbarPane();
156 
157  EDA_PANEINFO mesg;
158  mesg.MessageToolbarPane();
159 
160  // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
161  // the Layers Manager is floatable, but initially docked at far right
162  EDA_PANEINFO lyrs;
163  lyrs.LayersToolbarPane();
164  lyrs.MinSize( m_LayersManager->GetBestSize() );
165  lyrs.BestSize( m_LayersManager->GetBestSize() );
166  lyrs.Caption( _( "Visibles" ) );
167  lyrs.TopDockable( false ).BottomDockable( false );
168 
169 
170  if( m_mainToolBar )
171  m_auimgr.AddPane( m_mainToolBar,
172  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
173 
174  if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows component and netname lists
175  {
176  m_auimgr.AddPane( m_auxiliaryToolBar,
177  wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
178  }
179 
180  if( m_drawToolBar )
181  m_auimgr.AddPane( m_drawToolBar,
182  wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) );
183 
184  m_auimgr.AddPane( m_LayersManager,
185  lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 0 ) );
186 
187  if( m_optionsToolBar )
188  m_auimgr.AddPane( m_optionsToolBar,
189  wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
190 
191  if( m_canvas )
192  m_auimgr.AddPane( m_canvas,
193  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
194 
195  if( GetGalCanvas() )
196  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
197  wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
198 
199  if( m_messagePanel )
200  m_auimgr.AddPane( m_messagePanel,
201  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) );
202 
203  ReFillLayerWidget(); // this is near end because contents establish size
204  m_auimgr.Update();
205 
206  setupTools();
207 
208  SetActiveLayer( 0, true );
209  Zoom_Automatique( false ); // Gives a default zoom value
210 
212 
213  // Nudge user to switch to OpenGL if they are on legacy or Cairo
214  if( m_firstRunDialogSetting < 1 )
215  {
216  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
217  {
218  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
219  "and faster experience. This option is turned off by "
220  "default since it is not compatible with all computers.\n\n"
221  "Would you like to try enabling graphics acceleration?\n\n"
222  "If you'd like to choose later, select Modern Toolset "
223  "(Accelerated) in the Preferences menu." );
224 
225  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ),
226  wxYES_NO );
227 
228  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
229 
230  if( dlg.ShowModal() == wxID_YES )
231  {
232  // Save Cairo as default in case OpenGL crashes
234 
235  // Switch to OpenGL, which will save the new setting if successful
236  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL );
237  auto handler = GetEventHandler();
238  handler->ProcessEvent( evt );
239  }
240  else
241  {
242  // If they were on legacy, switch them to Cairo
243 
244  if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
245  {
246  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
247  auto handler = GetEventHandler();
248  handler->ProcessEvent( evt );
249  }
250  }
251  }
252 
254  SaveSettings( config() );
255  }
256 
257  // Canvas may have been updated by the dialog
258  canvasType = loadCanvasTypeSetting();
259 
260  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
261  {
262  if( GetGalCanvas()->SwitchBackend( canvasType ) )
263  UseGalCanvas( true );
264 
265  wxUpdateUIEvent e;
267  }
268  else
269  {
271  m_canvas->Refresh();
272  }
273 
274  // Enable the axes to match legacy draw style
275  auto& galOptions = GetGalDisplayOptions();
276  galOptions.m_axesEnabled = true;
277  galOptions.NotifyChanged();
278 
280  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
281 }
282 
283 
285 {
286  GetGalCanvas()->GetView()->Clear();
287 
289  delete m_gerberLayout;
290 }
291 
292 
293 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
294 {
295  GetGalCanvas()->GetView()->Clear();
297 
298  if( m_toolManager )
300 
301  if( IsGalCanvasActive() )
302  {
303  // Be sure any OpenGL event cannot be fired after frame deletion:
304  GetGalCanvas()->SetEvtHandlerEnabled( false );
305  }
306 
307  Destroy();
308 }
309 
310 
311 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
312 {
313  // The current project path is also a valid command parameter. Check if a single path
314  // rather than a file name was passed to GerbView and use it as the initial MRU path.
315  if( aFileSet.size() > 0 )
316  {
317  wxString path = aFileSet[0];
318 
319  // For some reason wxApp appears to leave the trailing double quote on quoted
320  // parameters which are required for paths with spaces. Maybe this should be
321  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
322  // We can't buy a break!
323  if( path.Last() == wxChar( '\"' ) )
324  path.RemoveLast();
325 
326  if( !wxFileExists( path ) && wxDirExists( path ) )
327  {
328  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
329  m_mruPath = path;
330  return true;
331  }
332 
333  const unsigned limit = std::min( unsigned( aFileSet.size() ),
334  unsigned( GERBER_DRAWLAYERS_COUNT ) );
335 
336  int layer = 0;
337 
338  for( unsigned i = 0; i < limit; ++i, ++layer )
339  {
340  SetActiveLayer( layer );
341 
342  // Try to guess the type of file by its ext
343  // if it is .drl (Kicad files), it is a drill file
344  wxFileName fn( aFileSet[i] );
345  wxString ext = fn.GetExt();
346 
347  if( ext == DrillFileExtension ) // In Excellon format
348  LoadExcellonFiles( aFileSet[i] );
349  else if( ext == GerberJobFileExtension )
350  LoadGerberJobFile( aFileSet[i] );
351  else
352  LoadGerberFiles( aFileSet[i] );
353  }
354  }
355 
356  Zoom_Automatique( true ); // Zoom fit in frame
357 
358  return true;
359 }
360 
361 
363 {
364  double defaultGerberZoom = 1.0;
366 
367  if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
368  {
369  SetScrollCenterPosition( wxPoint( 0, 0 ) );
370  return defaultGerberZoom;
371  }
372 
373  double sizeX = (double) bbox.GetWidth();
374  double sizeY = (double) bbox.GetHeight();
375  wxPoint centre = bbox.Centre();
376 
377  // Reserve no margin because GetGerberLayout()->ComputeBoundingBox() builds one in.
378  double margin_scale_factor = 1.0;
379 
380  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
381 }
382 
383 
384 void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
385 {
387 
388  // was: wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
390 
391  PAGE_INFO pageInfo( wxT( "GERBER" ) );
392 
394 
396  {
397  wxString pageType;
398  aCfg->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
399  pageInfo.SetType( pageType );
400  }
401 
402  SetPageSettings( pageInfo );
403 
404  GetScreen()->InitDataPoints( pageInfo.GetSizeIU() );
405 
406  bool tmp;
407  aCfg->Read( cfgShowDCodes, &tmp, true );
409  aCfg->Read( cfgShowNegativeObjects, &tmp, false );
411 
412  // because we have more than one file history, we must read this one
413  // using a specific path
414  aCfg->SetPath( wxT( "drl_files" ) );
415  m_drillFileHistory.Load( *aCfg );
416  aCfg->SetPath( wxT( ".." ) );
417 
418  // because we have more than one file history, we must read this one
419  // using a specific path
420  aCfg->SetPath( wxT( "zip_files" ) );
421  m_zipFileHistory.Load( *aCfg );
422  aCfg->SetPath( wxT( ".." ) );
423 
424  // because we have more than one file history, we must read this one
425  // using a specific path
426  aCfg->SetPath( "job_files" );
427  m_jobFileHistory.Load( *aCfg );
428  aCfg->SetPath( wxT( ".." ) );
429 }
430 
431 
432 void GERBVIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
433 {
435 
436  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
438 
439  aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
441  aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
442  aCfg->Write( cfgShowNegativeObjects,
444 
445  // Save the drill file history list.
446  // Because we have more than one file history, we must save this one
447  // in a specific path
448  aCfg->SetPath( wxT( "drl_files" ) );
449  m_drillFileHistory.Save( *aCfg );
450  aCfg->SetPath( wxT( ".." ) );
451 
452  // Save the zip file history list.
453  aCfg->SetPath( wxT( "zip_files" ) );
454  m_zipFileHistory.Save( *aCfg );
455  aCfg->SetPath( wxT( ".." ) );
456 
457  // Save the job file history list.
458  aCfg->SetPath( "job_files" );
459  m_jobFileHistory.Save( *aCfg );
460  aCfg->SetPath( ".." );
461 }
462 
463 
465 {
469 
470  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
471 
472  wxSize bestz = m_LayersManager->GetBestSize();
473  bestz.x += 5; // gives a little margin
474 
475  lyrs.MinSize( bestz );
476  lyrs.BestSize( bestz );
477  lyrs.FloatingSize( bestz );
478 
479  if( lyrs.IsDocked() )
480  m_auimgr.Update();
481  else
482  m_LayersManager->SetSize( bestz );
483 
484  syncLayerWidget();
485 }
486 
487 
489  bool aNewState )
490 {
491  bool dcodes_changed = false;
492 
493  switch( aItemIdVisible )
494  {
495  case LAYER_DCODES:
496  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
497  m_DisplayOptions.m_DisplayDCodes = aNewState;
498  break;
499 
501  {
503 
504  auto view = GetGalCanvas()->GetView();
505 
507  []( KIGFX::VIEW_ITEM* aItem ) {
508  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
509 
510  // GetLayerPolarity() returns true for negative items
511  return item->GetLayerPolarity();
512  } );
513  break;
514  }
515 
516  case LAYER_GERBVIEW_GRID:
517  SetGridVisibility( aNewState );
518  break;
519 
520  default:
521  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aItemIdVisible );
522  }
523 
524  if( dcodes_changed )
525  {
526  auto view = GetGalCanvas()->GetView();
527 
528  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
529  {
530  int layer = GERBER_DRAW_LAYER( i );
531  int dcode_layer = GERBER_DCODE_LAYER( layer );
532  view->SetLayerVisible( dcode_layer,
533  aNewState && view->IsLayerVisible( layer ) );
534  }
535  }
536 
538  m_LayersManager->SetRenderState( aItemIdVisible, aNewState );
539 }
540 
541 
543 {
544  auto view = GetGalCanvas()->GetView();
545  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
546  auto settings = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( painter->GetSettings() );
547  settings->LoadDisplayOptions( &m_DisplayOptions );
548 
549  settings->ImportLegacyColors( m_colorsSettings );
550 
551  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
552 }
553 
554 
556 {
557  int layer = aLayer;
558 
559  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
560  {
561  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
562 
563  if( gerber == NULL ) // this graphic layer is available: use it
564  return layer;
565 
566  ++layer; // try next graphic layer
567 
568  if( layer >= (int)ImagesMaxCount() )
569  layer = 0;
570  }
571 
572  return NO_AVAILABLE_LAYERS;
573 }
574 
575 
577 {
579 }
580 
581 
582 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
583 {
584  if( aRebuildLayerBox )
586 
587  m_SelLayerBox->SetSelection( GetActiveLayer() );
588 
589  int dcodeSelected = -1;
591 
592  if( gerber )
593  dcodeSelected = gerber->m_Selected_Tool;
594 
595  if( m_DCodeSelector )
596  {
598  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
599  m_DCodeSelector->Enable( gerber != NULL );
600  }
601 }
602 
603 
605 {
606  int ii, jj;
607  wxString Line;
608  wxArrayString list;
609  double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
610  int curr_layer = GetActiveLayer();
611 
612  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
613  {
614  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
615 
616  if( gerber == NULL )
617  continue;
618 
619  if( gerber->GetDcodesCount() == 0 )
620  continue;
621 
622  if( layer == curr_layer )
623  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
624  else
625  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
626 
627  list.Add( Line );
628 
629  const char* units = g_UserUnit == INCHES ? "\"" : "mm";
630 
631  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
632  {
633  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
634 
635  if( pt_D_code == NULL )
636  continue;
637 
638  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
639  continue;
640 
641  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
642  jj,
643  pt_D_code->m_Num_Dcode,
644  pt_D_code->m_Size.y / scale, units,
645  pt_D_code->m_Size.x / scale, units,
646  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
647  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
648  );
649 
650  if( !pt_D_code->m_Defined )
651  Line += wxT( " (not defined)" );
652 
653  if( pt_D_code->m_InUse )
654  Line += wxT( " (in use)" );
655 
656  list.Add( Line );
657  jj++;
658  }
659  }
660 
661  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
662  wxCHOICEDLG_STYLE & ~wxCANCEL );
663 
664  dlg.ShowModal();
665 }
666 
667 
669 {
670  auto remapping = GetImagesList()->SortImagesByZOrder();
671 
673  syncLayerBox( true );
674 
675  std::unordered_map<int, int> view_remapping;
676 
677  for( auto it : remapping )
678  {
679  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
680  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
681  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
682  }
683 
684  GetGalCanvas()->GetView()->ReorderLayerData( view_remapping );
685  GetCanvas()->Refresh();
686 }
687 
688 
690 {
691  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
692  aOptions.m_DisplayFlashedItemsFill );
693  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
694  aOptions.m_DisplayLinesFill );
695  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
696  aOptions.m_DisplayPolygonsFill );
697 
698  m_DisplayOptions = aOptions;
699 
701 
702  auto view = GetGalCanvas()->GetView();
703 
704  if( update_flashed )
705  {
707  []( KIGFX::VIEW_ITEM* aItem ) {
708  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
709 
710  switch( item->m_Shape )
711  {
712  case GBR_SPOT_CIRCLE:
713  case GBR_SPOT_RECT:
714  case GBR_SPOT_OVAL:
715  case GBR_SPOT_POLY:
716  case GBR_SPOT_MACRO:
717  return true;
718 
719  default:
720  return false;
721  }
722  } );
723  }
724  else if( update_lines )
725  {
726  view->UpdateAllItemsConditionally( KIGFX::REPAINT,
727  []( KIGFX::VIEW_ITEM* aItem ) {
728  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
729 
730  switch( item->m_Shape )
731  {
732  case GBR_CIRCLE:
733  case GBR_ARC:
734  case GBR_SEGMENT:
735  return true;
736 
737  default:
738  return false;
739  }
740  } );
741  }
742  else if( update_polygons )
743  {
744  view->UpdateAllItemsConditionally( KIGFX::REPAINT,
745  []( KIGFX::VIEW_ITEM* aItem ) {
746  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
747 
748  return ( item->m_Shape == GBR_POLYGON );
749  } );
750  }
751 
752  view->UpdateAllItems( KIGFX::COLOR );
753 
754  m_canvas->Refresh( true );
755 }
756 
757 
759 {
761 
762  // Display the gerber filename
763  if( gerber == NULL )
764  {
765  SetTitle( "GerbView" );
766 
767  SetStatusText( wxEmptyString, 0 );
768 
769  wxString info;
770  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
771  m_TextInfo->SetValue( info );
772 
773  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
774  m_auimgr.Update();
775 
776  ClearMsgPanel();
777  return;
778  }
779  else
780  {
781  wxString title;
782  title.Printf( _( "GerbView" ) + wxT( " \u2014 %s%s" ),
783  gerber->m_FileName,
784  gerber->m_IsX2_file ? _( " (with X2 attributes)" )
785  : wxString( wxEmptyString ) );
786  SetTitle( title );
787 
788  gerber->DisplayImageInfo( this );
789 
790  // Display Image Name and Layer Name (from the current gerber data):
791  wxString status;
792  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
793  GetChars( gerber->m_ImageName ),
794  GetChars( gerber->GetLayerParams().m_LayerName ) );
795  SetStatusText( status, 0 );
796 
797  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
798  wxString info;
799  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
800  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
801  gerber->m_FmtLen.x - gerber->m_FmtScale.x, gerber->m_FmtScale.x,
802  gerber->m_FmtLen.y - gerber->m_FmtScale.y, gerber->m_FmtScale.y,
803  gerber->m_NoTrailingZeros ? 'T' : 'L' );
804 
805  if( gerber->m_IsX2_file )
806  info << wxT(" ") << _( "X2 attr" );
807 
808  m_TextInfo->SetValue( info );
809 
810  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
811  m_auimgr.Update();
812  }
813 }
814 
815 
817 {
818  switch( aItemIdVisible )
819  {
820  case LAYER_DCODES:
822  break;
823 
826  break;
827 
828  case LAYER_GERBVIEW_GRID:
829  return IsGridVisible();
830  break;
831 
832  default:
833  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aItemIdVisible );
834  }
835 
836  return true;
837 }
838 
839 
841 {
842  long layerMask = 0;
843 
844  if( auto canvas = GetGalCanvas() )
845  {
846  // NOTE: This assumes max 32 drawlayers!
847  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
848  {
849  if( canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) )
850  layerMask |= ( 1 << i );
851  }
852 
853  return layerMask;
854  }
855  else
856  {
857  return -1;
858  }
859 }
860 
861 
862 void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask )
863 {
864  if( auto canvas = GetGalCanvas() )
865  {
866  // NOTE: This assumes max 32 drawlayers!
867  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
868  {
869  bool v = ( aLayerMask & ( 1 << i ) );
870  int layer = GERBER_DRAW_LAYER( i );
871  canvas->GetView()->SetLayerVisible( layer, v );
872  canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
874  }
875  }
876 }
877 
878 
879 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
880 {
882  return m_LayersManager->IsLayerVisible( aLayer );
883  else
884  return GetGerberLayout()->IsLayerPrintable( aLayer );
885 }
886 
887 
889 {
890  COLOR4D color = COLOR4D::UNSPECIFIED;
891 
892  switch( aItemIdVisible )
893  {
895  case LAYER_DCODES:
896  color = m_colorsSettings->GetItemColor( aItemIdVisible );
897  break;
898 
899  case LAYER_GERBVIEW_GRID:
900  color = GetGridColor();
901  break;
902 
903  default:
904  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
905  (int)aItemIdVisible );
906  }
907 
908  return color;
909 }
910 
911 
913 {
916 }
917 
918 
920  COLOR4D aColor )
921 {
922  switch( aItemIdVisible )
923  {
925  case LAYER_DCODES:
926  m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
927  break;
928 
929  case LAYER_GERBVIEW_GRID:
930  // Ensure grid always has low alpha
931  aColor.a = 0.8;
932  SetGridColor( aColor );
933  m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
934  break;
935 
936  default:
937  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ),
938  (int) aItemIdVisible );
939  }
940 }
941 
943 {
946  else
947  return GetDrawBgColor();
948 }
949 
950 
952 {
953  return m_colorsSettings->GetLayerColor( aLayer );
954 }
955 
956 
957 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
958 {
959  m_colorsSettings->SetLayerColor( aLayer, aColor );
961 }
962 
963 
965 {
966  return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
967 }
968 
969 
970 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
971 {
972  ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
973 
974  if( doLayerWidgetUpdate )
976 
978 
979  if( IsGalCanvasActive() )
980  {
981  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
982  GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
983 
985 
986  GetGalCanvas()->Refresh();
987  }
988 }
989 
990 
991 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
992 {
993  m_paper = aPageSettings;
994 
995  if( GetScreen() )
996  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
997 }
998 
999 
1001 {
1002  return m_paper;
1003 }
1004 
1005 
1006 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
1007 {
1008  // this function is only needed because EDA_DRAW_FRAME is not compiled
1009  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
1010  // into an application specific source file.
1011  return GetPageSettings().GetSizeIU();
1012 }
1013 
1014 
1016 {
1017  wxASSERT( m_gerberLayout );
1018  return m_gerberLayout->GetTitleBlock();
1019 }
1020 
1021 
1022 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
1023 {
1024  wxASSERT( m_gerberLayout );
1025  m_gerberLayout->SetTitleBlock( aTitleBlock );
1026 }
1027 
1028 
1030 {
1031  wxASSERT( m_gerberLayout );
1032  return m_gerberLayout->GetAuxOrigin();
1033 }
1034 
1035 
1036 void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
1037 {
1038  wxASSERT( m_gerberLayout );
1039  m_gerberLayout->SetAuxOrigin( aPosition );
1040 }
1041 
1042 
1043 void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
1044 {
1045  GetScreen()->SetCurItem( aItem );
1046 
1047  if( aItem )
1048  {
1049  if( aDisplayInfo )
1050  {
1051  MSG_PANEL_ITEMS items;
1052  aItem->GetMsgPanelInfo( items );
1053  SetMsgPanel( items );
1054  }
1055  }
1056  else
1057  {
1058  EraseMsgBox();
1059  }
1060 }
1061 
1062 
1064 {
1065  if( IsGalCanvasActive() )
1066  {
1067  GetGalCanvas()->GetGAL()->SetGridColor( aColor );
1068  }
1069 
1070  m_gridColor = aColor;
1071 }
1072 
1073 
1075 {
1077  return GetGerberLayout()->GetBoundingBox();
1078 }
1079 
1080 
1082 {
1084 
1085  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
1086 
1087  if( !screen )
1088  return;
1089 
1090  int dx;
1091  int dy;
1092  double dXpos;
1093  double dYpos;
1094  wxString line;
1095  wxString locformatter;
1096 
1097  if( m_DisplayOptions.m_DisplayPolarCood ) // display relative polar coordinates
1098  {
1099  double theta, ro;
1100 
1101  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1102  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1103 
1104  // atan2 in the 0,0 case returns 0
1105  theta = RAD2DEG( atan2( (double) -dy, (double) dx ) );
1106 
1107  ro = hypot( dx, dy );
1108  wxString formatter;
1109  switch( g_UserUnit )
1110  {
1111  case INCHES:
1112  formatter = wxT( "Ro %.6f Th %.1f" );
1113  break;
1114 
1115  case MILLIMETRES:
1116  formatter = wxT( "Ro %.5f Th %.1f" );
1117  break;
1118 
1119  case UNSCALED_UNITS:
1120  formatter = wxT( "Ro %f Th %f" );
1121  break;
1122 
1123  case DEGREES:
1124  wxASSERT( false );
1125  break;
1126  }
1127 
1128  line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta );
1129 
1130  SetStatusText( line, 3 );
1131  }
1132 
1133  // Display absolute coordinates:
1136 
1137  wxString absformatter;
1138 
1139  switch( g_UserUnit )
1140  {
1141  case INCHES:
1142  absformatter = wxT( "X %.6f Y %.6f" );
1143  locformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1144  break;
1145 
1146  case MILLIMETRES:
1147  absformatter = wxT( "X %.5f Y %.5f" );
1148  locformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1149  break;
1150 
1151  case UNSCALED_UNITS:
1152  absformatter = wxT( "X %f Y %f" );
1153  locformatter = wxT( "dx %f dy %f dist %f" );
1154  break;
1155 
1156  case DEGREES:
1157  wxASSERT( false );
1158  break;
1159  }
1160 
1161  line.Printf( absformatter, dXpos, dYpos );
1162  SetStatusText( line, 2 );
1163 
1164  if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates
1165  {
1166  // Display relative coordinates:
1167  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1168  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1169  dXpos = To_User_Unit( g_UserUnit, dx );
1170  dYpos = To_User_Unit( g_UserUnit, dy );
1171 
1172  // We already decided the formatter above
1173  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1174  SetStatusText( line, 3 );
1175  }
1176 }
1177 
1178 
1180 {
1182 }
1183 
1184 
1186 {
1187  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1188 }
1189 
1190 
1192 {
1194 }
1195 
1196 
1198 { // Called on units change (see EDA_DRAW_FRAME)
1201 }
1202 
1203 
1204 void GERBVIEW_FRAME::UseGalCanvas( bool aEnable )
1205 {
1206  EDA_DRAW_FRAME::UseGalCanvas( aEnable );
1207 
1208  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1209 
1210  if( m_toolManager )
1212  GetGalCanvas()->GetViewControls(), this );
1213 
1214  if( aEnable )
1215  {
1216  if( m_toolManager )
1218 
1219  m_colorsSettings->SetLegacyMode( false );
1220 
1222 
1223  galCanvas->GetView()->RecacheAllItems();
1224  galCanvas->SetEventDispatcher( m_toolDispatcher );
1225  galCanvas->StartDrawing();
1226  }
1227  else
1228  {
1229  if( m_toolManager )
1231 
1232  galCanvas->StopDrawing();
1233 
1234  // Redirect all events to the legacy canvas
1235  galCanvas->SetEventDispatcher( NULL );
1236 
1238  m_canvas->Refresh();
1239  }
1240 
1243 
1245  ReCreateMenuBar();
1246 }
1247 
1248 
1250 {
1251  // Create the manager and dispatcher & route draw panel events to the dispatcher
1254  GetGalCanvas()->GetViewControls(), this );
1255  m_actions = new GERBVIEW_ACTIONS();
1257 
1258  // Register tools
1261 
1262  // Run the selection tool, it is supposed to be always active
1263  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1264 }
1265 
1266 
1268 {
1269  int scale = 0;
1270  Kiface().KifaceSettings()->Read( IconScaleEntry, &scale, 0 );
1271  return scale;
1272 }
1273 
1274 
1276 {
1277  Kiface().KifaceSettings()->Write( IconScaleEntry, aScale );
1278  ReCreateMenuBar();
1279  ReCreateHToolbar();
1282  Layout();
1283  SendSizeEvent();
1284 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:100
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
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
static const wxString cfgShowBorderAndTitleBlock(wxT("ShowBorderAndTitleBlock"))
static TOOL_ACTION layerChanged
void SortLayersByX2Attributes()
virtual void SetHighContrastLayer(int aLayer)
Function SetHighContrastLayer Takes care of display settings for the given layer to be displayed in h...
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox.
Definition: gbr_layout.h:105
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:1390
const wxSize GetPageSizeIU() const override
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
void SetIconScale(int aScale) override
Function SetIconScale.
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE...
COLORS_DESIGN_SETTINGS g_ColorsSettings(FRAME_GERBER)
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:916
bool m_showAxis
True shows the X and Y axis indicators.
Definition: draw_frame.h:108
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:736
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
void DeleteAllImages()
remove all loaded data in list, and delete all images.
bool IsLayerPrintable(int aLayer) const
Function IsLayerPrintable tests whether a given layer is visible.
Definition: gbr_layout.cpp:56
EDA_RECT GetGerberLayoutBoundingBox()
Function GetGerberLayoutBoundingBox calculates the bounding box containing all gerber items...
Implementation of conversion functions that require both schematic and board internal units...
COLOR4D GetNegativeItemsColor()
Function GetNegativeItemsColor.
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:101
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:351
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
void SetVisibleElementColor(GERBVIEW_LAYER_ID aItemIdVisible, COLOR4D aColor)
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
Definition: zoom.cpp:86
void SetAuxOrigin(const wxPoint &aPoint) override
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
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:159
static const wxString IconScaleEntry
const wxPoint & GetAuxOrigin() const override
Function GetAuxOrigin returns the origin of the axis used for plotting and various exports...
void SetScrollCenterPosition(const wxPoint &aPoint)
const wxPoint & GetAuxOrigin() const
Definition: gbr_layout.h:75
void SetPageSettings(const PAGE_INFO &aPageSettings) override
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...
void UseDrawPriority(bool aFlag)
Function UseDrawPriority()
Definition: view.h:651
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:1335
double RAD2DEG(double rad)
Definition: trigo.h:200
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
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...
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
int GetHeight() const
Definition: eda_rect.h:118
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void SetAuxOrigin(const wxPoint &aPosition)
Definition: gbr_layout.h:80
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
static const wxString cfgShowNegativeObjects(wxT("ShowNegativeObjectsOpt"))
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
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:896
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
wxFileHistory m_drillFileHistory
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
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
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:55
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
int GetActiveLayer()
Function SetActiveLayer returns the active layer.
void SetVisibleLayers(long aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:39
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
COLOR4D m_gridColor
Grid color.
Definition: draw_frame.h:88
virtual void UseGalCanvas(bool aEnable)
Function UseGalCanvas used to switch between standard and GAL-based canvas.
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:793
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
GERBVIEW_LAYER_ID
GerbView draw layers.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
Specialization of the wxAuiPaneInfo class for KiCad panels.
EDA_RECT ComputeBoundingBox() const
Function ComputeBoundingBox calculates the bounding box containing all Gerber items.
Definition: gbr_layout.cpp:68
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
virtual bool IsGridVisible() const
Function IsGridVisible() , virtual.
Definition: draw_frame.h:498
wxChoice * m_SelNetnameBox
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
int getNextAvailableLayer(int aLayer=0) const
Function getNextAvailableLayer finds the next empty layer starting at aLayer and returns it to the ca...
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.
long GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
Auxiliary rendering target (noncached)
Definition: definitions.h:42
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.
#define GERBER_DCODE_LAYER(x)
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:69
Class TOOL_MANAGER.
Definition: tool_manager.h:49
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:102
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
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.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
double a
Alpha component.
Definition: color4d.h:294
wxAuiToolBar * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window...
Definition: draw_frame.h:131
Item is being added to the view.
Definition: view_item.h:60
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:361
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Updates the display options and refreshes the view as needed.
COLOR4D GetVisibleElementColor(GERBVIEW_LAYER_ID aItemIdVisible)
Function GetVisibleElementColor returns the color of a gerber visible element.
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:138
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString)
Function EnsureTextCtrlWidth sets the minimum pixel width on a text control in order to make a text s...
Definition: common.cpp:109
unsigned ImagesMaxCount() const
The max number of file images.
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:338
PAGE_INFO m_paper
void ReCreateAuxiliaryToolbar() override
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:81
virtual void unitsChangeRefresh() override
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
#define GERBER_DRAWLAYERS_COUNT
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:832
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
bool GetLayerPolarity() const
void EraseMsgBox()
Definition: draw_frame.cpp:275
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
Class GERBVIEW_PAINTER Contains methods for drawing GerbView-specific items.
#define FIRST_DCODE
Definition: dcode.h:71
#define NO_AVAILABLE_LAYERS
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1051
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:141
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:49
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:118
Definition: common.h:145
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
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 wxString DrillFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:85
The common library.
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.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
GBR_LAYOUT * m_gerberLayout
wxFileHistory m_jobFileHistory
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:887
virtual void SetFocus() override
GBR_LAYOUT * GetGerberLayout() const
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:654
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
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
wxPoint Centre() const
Definition: eda_rect.h:60
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void OnCloseWindow(wxCloseEvent &Event)
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible tests whether a given layer is visible.
Class GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
int m_LastGridSizeId
Definition: draw_frame.h:83
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:517
#define GERBVIEW_FRAME_NAME
Class GERBVIEW_FRAME is the main window used in GerbView.
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:135
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:761
#define ZOOM_FACTOR(x)
Definition: pcb_screen.cpp:42
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting() const
Returns the canvas type stored in the application settings.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
const wxString GerberJobFileExtension
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
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
wxFileHistory m_zipFileHistory
const PAGE_INFO & GetPageSettings() const override
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:98
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id...
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:91
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:92
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 SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools...
void SetElementVisibility(GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:50
int GetIconScale() override
Function GetIconScale.
size_t i
Definition: json11.cpp:597
bool IsElementVisible(GERBVIEW_LAYER_ID aItemIdVisible) const
Function IsElementVisible tests whether a given element category is visible.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[]
void SetLayerColor(int aLayer, COLOR4D aColor)
Function SetLayerColor changes a layer color for any valid layer.
int GetWidth() const
Definition: eda_rect.h:117
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
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
double To_User_Unit(EDA_UNITS_T aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:91
void SetLegacyMode(bool aMode)
Enables or disables legacy color mode.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:895
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual void SetGridVisibility(bool aVisible)
Function SetGridVisibility() , virtual It may be overloaded by derived classes.
Definition: draw_frame.h:508
#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.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
virtual void unitsChangeRefresh()
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
Definition: draw_frame.cpp:268
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
virtual void RegisterAllTools(TOOL_MANAGER *aToolManager)=0
Registers all valid tools for an application with the tool manager
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...
ACTIONS * m_actions
Definition: draw_frame.h:102
bool m_IsPrinting
true when printing a page, false when drawing on screen
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
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()
Function UpdateStatusBar updates the status bar information.
Definition: draw_frame.cpp:725
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void Liste_D_Codes()
Set Size Items (Lines, Flashes) from DCodes List.
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:823
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:121
static const wxString cfgShowPageSizeOption(wxT("PageSizeOpt"))
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
#define min(a, b)
Definition: auxiliary.h:85
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:90
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