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 #include <eda_dockart.h>
38 
39 #include <gerbview.h>
40 #include <gerbview_frame.h>
41 #include <gerbview_id.h>
42 #include <hotkeys.h>
43 #include <gerber_file_image.h>
44 #include <gerber_file_image_list.h>
45 #include <dialog_helpers.h>
46 #include <DCodeSelectionbox.h>
47 #include <gerbview_layer_widget.h>
48 
51 #include <tool/tool_manager.h>
52 #include <tool/tool_dispatcher.h>
53 #include <tools/gerbview_actions.h>
54 #include <view/view.h>
55 #include <gerbview_painter.h>
56 
57 
58 // Config keywords
59 static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
60 static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
61 static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
62 static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
63 
64 // Colors for layers and items
66 
67 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
68  EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
69  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ),
73 {
75  m_gerberLayout = NULL;
76  m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
77  // when the screen shows a 1:1 image
78  // obviously depends on the monitor,
79  // but this is an acceptable value
80 
81  // Be sure a page info is set. this default value will be overwritten later.
82  PAGE_INFO pageInfo( wxT( "GERBER" ) );
83  SetPageSettings( pageInfo );
84 
86 
87  m_showAxis = true; // true to show X and Y axis on screen
88  m_showBorderAndTitleBlock = false; // true for reference drawings.
90  m_SelLayerBox = NULL;
91  m_DCodeSelector = NULL;
92  m_SelComponentBox = nullptr;
93  m_SelNetnameBox = nullptr;
94  m_SelAperAttributesBox = nullptr;
95  m_displayMode = 0;
96 
97  int fileHistorySize;
98  Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize, DEFAULT_FILE_HISTORY_SIZE );
99  m_drillFileHistory.SetMaxFiles( fileHistorySize );
100  m_zipFileHistory.SetMaxFiles( fileHistorySize );
101  m_jobFileHistory.SetMaxFiles( fileHistorySize );
102 
103  EDA_DRAW_PANEL_GAL* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
104  m_FrameSize,
107 
108  SetGalCanvas( galCanvas );
109 
110  // GerbView requires draw priority for rendering negative objects
111  galCanvas->GetView()->UseDrawPriority( true );
112 
113  if( m_canvas )
115 
116  // Give an icon
117  wxIcon icon;
118  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
119  SetIcon( icon );
120 
121  SetLayout( new GBR_LAYOUT() );
122 
123  SetVisibleLayers( -1 ); // All draw layers visible.
124 
125  SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
126 
127  // Create the PCB_LAYER_WIDGET *after* SetLayout():
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  ReCreateMenuBar();
148 
149  m_auimgr.SetManagedWindow( this );
150  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
151 
152  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
153  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
154  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
155 
156  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
157  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
158  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
159  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
160 
161  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
162  m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
163 
164  ReFillLayerWidget(); // this is near end because contents establish size
165  m_auimgr.Update();
166 
167  setupTools();
168 
169  SetActiveLayer( 0, true );
170  Zoom_Automatique( false ); // Gives a default zoom value
171 
173 
174  // Nudge user to switch to OpenGL if they are on legacy or Cairo
175  if( m_firstRunDialogSetting < 1 )
176  {
177  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
178  {
179  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
180  "and faster experience. This option is turned off by "
181  "default since it is not compatible with all computers.\n\n"
182  "Would you like to try enabling graphics acceleration?\n\n"
183  "If you'd like to choose later, select Modern Toolset "
184  "(Accelerated) in the Preferences menu." );
185 
186  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
187 
188  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
189 
190  if( dlg.ShowModal() == wxID_YES )
191  {
192  // Save Cairo as default in case OpenGL crashes
194 
195  // Switch to OpenGL, which will save the new setting if successful
196  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL );
197  GetEventHandler()->ProcessEvent( evt );
198 
199  // Switch back to Cairo if OpenGL is not supported
200  if( GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
201  {
202  wxCommandEvent cairoEvt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
203  GetEventHandler()->ProcessEvent( cairoEvt );
204  }
205  }
206  else if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
207  {
208  // If they were on legacy, switch them to Cairo
209  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
210  GetEventHandler()->ProcessEvent( evt );
211  }
212  }
213 
215  SaveSettings( config() );
216  }
217  else if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
218  {
219  if( GetGalCanvas()->SwitchBackend( canvasType ) )
220  UseGalCanvas( true );
221 
222  wxUpdateUIEvent e;
224  }
225  else
226  {
228  m_canvas->Refresh();
229  }
230 
231  // Enable the axes to match legacy draw style
232  auto& galOptions = GetGalDisplayOptions();
233  galOptions.m_axesEnabled = true;
234  galOptions.NotifyChanged();
235 
237  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
238 }
239 
240 
242 {
243  GetGalCanvas()->GetView()->Clear();
244 
246  delete m_gerberLayout;
247 }
248 
249 
250 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
251 {
252  GetGalCanvas()->GetView()->Clear();
254 
255  if( m_toolManager )
257 
258  if( IsGalCanvasActive() )
259  {
260  // Be sure any OpenGL event cannot be fired after frame deletion:
261  GetGalCanvas()->SetEvtHandlerEnabled( false );
262  }
263 
264  Destroy();
265 }
266 
267 
268 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
269 {
270  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
271  // when trying to change the view if it is not fully initialized.
272  // It happens when starting Gerbview with a gerber job file to load
273  if( !IsShown() )
274  Show();
275 
276  // The current project path is also a valid command parameter. Check if a single path
277  // rather than a file name was passed to GerbView and use it as the initial MRU path.
278  if( aFileSet.size() > 0 )
279  {
280  wxString path = aFileSet[0];
281 
282  // For some reason wxApp appears to leave the trailing double quote on quoted
283  // parameters which are required for paths with spaces. Maybe this should be
284  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
285  // We can't buy a break!
286  if( path.Last() == wxChar( '\"' ) )
287  path.RemoveLast();
288 
289  if( !wxFileExists( path ) && wxDirExists( path ) )
290  {
291  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
292  m_mruPath = path;
293  return true;
294  }
295 
296  const unsigned limit = std::min( unsigned( aFileSet.size() ),
297  unsigned( GERBER_DRAWLAYERS_COUNT ) );
298 
299  int layer = 0;
300 
301  for( unsigned i = 0; i < limit; ++i, ++layer )
302  {
303  SetActiveLayer( layer );
304 
305  // Try to guess the type of file by its ext
306  // if it is .drl (Kicad files), it is a drill file
307  wxFileName fn( aFileSet[i] );
308  wxString ext = fn.GetExt();
309 
310  if( ext == DrillFileExtension ) // In Excellon format
311  LoadExcellonFiles( aFileSet[i] );
312  else if( ext == GerberJobFileExtension )
313  LoadGerberJobFile( aFileSet[i] );
314  else
315  LoadGerberFiles( aFileSet[i] );
316  }
317  }
318 
319  Zoom_Automatique( true ); // Zoom fit in frame
320 
321  return true;
322 }
323 
324 
326 {
328 
329  // Reserve a margin around the bounding box, for a better display.
330  double margin_scale_factor = 1.05;
331 
332  // If there is not item loaded, use the current page size
333  if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
334  {
335  bbox.SetSize( GetPageSizeIU() );
336  bbox.SetOrigin( 0, 0 );
337  }
338 
339  double sizeX = (double) bbox.GetWidth();
340  double sizeY = (double) bbox.GetHeight();
341  wxPoint centre = bbox.Centre();
342 
343  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
344 }
345 
346 
347 void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
348 {
350 
351  // was: wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
353 
355 
356  PAGE_INFO pageInfo( wxT( "GERBER" ) );
357  wxString pageType;
358 
359  aCfg->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
360  pageInfo.SetType( pageType );
361  SetPageSettings( pageInfo );
362 
363  bool tmp;
364  aCfg->Read( cfgShowDCodes, &tmp, true );
366  aCfg->Read( cfgShowNegativeObjects, &tmp, false );
368 
369  // because we have more than one file history, we must read this one
370  // using a specific path
371  aCfg->SetPath( wxT( "drl_files" ) );
372  m_drillFileHistory.Load( *aCfg );
373  aCfg->SetPath( wxT( ".." ) );
374 
375  // because we have more than one file history, we must read this one
376  // using a specific path
377  aCfg->SetPath( wxT( "zip_files" ) );
378  m_zipFileHistory.Load( *aCfg );
379  aCfg->SetPath( wxT( ".." ) );
380 
381  // because we have more than one file history, we must read this one
382  // using a specific path
383  aCfg->SetPath( "job_files" );
384  m_jobFileHistory.Load( *aCfg );
385  aCfg->SetPath( wxT( ".." ) );
386 }
387 
388 
389 void GERBVIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
390 {
392 
393  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
395 
396  aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
398  aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
400 
401  // Save the drill file history list.
402  // Because we have more than one file history, we must save this one
403  // in a specific path
404  aCfg->SetPath( wxT( "drl_files" ) );
405  m_drillFileHistory.Save( *aCfg );
406  aCfg->SetPath( wxT( ".." ) );
407 
408  // Save the zip file history list.
409  aCfg->SetPath( wxT( "zip_files" ) );
410  m_zipFileHistory.Save( *aCfg );
411  aCfg->SetPath( wxT( ".." ) );
412 
413  // Save the job file history list.
414  aCfg->SetPath( "job_files" );
415  m_jobFileHistory.Save( *aCfg );
416  aCfg->SetPath( ".." );
417 }
418 
419 
421 {
425 
426  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
427  wxSize bestz = m_LayersManager->GetBestSize();
428  bestz.x += 5; // gives a little margin
429 
430  lyrs.MinSize( bestz );
431  lyrs.BestSize( bestz );
432  lyrs.FloatingSize( bestz );
433 
434  if( lyrs.IsDocked() )
435  m_auimgr.Update();
436  else
437  m_LayersManager->SetSize( bestz );
438 
439  syncLayerWidget();
440 }
441 
442 
443 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
444 {
445  bool dcodes_changed = false;
446 
447  switch( aLayerID )
448  {
449  case LAYER_DCODES:
450  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
451  m_DisplayOptions.m_DisplayDCodes = aNewState;
452  break;
453 
455  {
457 
458  auto view = GetGalCanvas()->GetView();
459 
461  {
462  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
463 
464  // GetLayerPolarity() returns true for negative items
465  return item->GetLayerPolarity();
466  } );
467  break;
468  }
469 
470  case LAYER_WORKSHEET:
471  m_showBorderAndTitleBlock = aNewState;
472  break;
473 
474  case LAYER_GERBVIEW_GRID:
475  SetGridVisibility( aNewState );
476  break;
477 
478  default:
479  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aLayerID );
480  }
481 
482  if( dcodes_changed )
483  {
484  auto view = GetGalCanvas()->GetView();
485 
486  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
487  {
488  int layer = GERBER_DRAW_LAYER( i );
489  int dcode_layer = GERBER_DCODE_LAYER( layer );
490  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
491  }
492  }
493 
495  m_LayersManager->SetRenderState( aLayerID, aNewState );
496 }
497 
498 
500 {
501  auto view = GetGalCanvas()->GetView();
502  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
503  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
504  settings->LoadDisplayOptions( &m_DisplayOptions );
505 
507 
508  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
509 }
510 
511 
513 {
514  int layer = aLayer;
515 
516  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
517  {
518  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
519 
520  if( gerber == NULL ) // this graphic layer is available: use it
521  return layer;
522 
523  ++layer; // try next graphic layer
524 
525  if( layer >= (int)ImagesMaxCount() )
526  layer = 0;
527  }
528 
529  return NO_AVAILABLE_LAYERS;
530 }
531 
532 
534 {
536 }
537 
538 
539 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
540 {
541  if( aRebuildLayerBox )
543 
544  m_SelLayerBox->SetSelection( GetActiveLayer() );
545 
546  int dcodeSelected = -1;
548 
549  if( gerber )
550  dcodeSelected = gerber->m_Selected_Tool;
551 
552  if( m_DCodeSelector )
553  {
555  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
556  m_DCodeSelector->Enable( gerber != NULL );
557  }
558 }
559 
560 
562 {
563  int ii, jj;
564  wxString Line;
565  wxArrayString list;
566  double scale = GetUserUnits() == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
567  int curr_layer = GetActiveLayer();
568 
569  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
570  {
571  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
572 
573  if( gerber == NULL )
574  continue;
575 
576  if( gerber->GetDcodesCount() == 0 )
577  continue;
578 
579  if( layer == curr_layer )
580  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
581  else
582  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
583 
584  list.Add( Line );
585 
586  const char* units = GetUserUnits() == INCHES ? "\"" : "mm";
587 
588  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
589  {
590  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
591 
592  if( pt_D_code == NULL )
593  continue;
594 
595  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
596  continue;
597 
598  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
599  jj,
600  pt_D_code->m_Num_Dcode,
601  pt_D_code->m_Size.y / scale, units,
602  pt_D_code->m_Size.x / scale, units,
603  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
604  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
605  );
606 
607  if( !pt_D_code->m_Defined )
608  Line += wxT( " (not defined)" );
609 
610  if( pt_D_code->m_InUse )
611  Line += wxT( " (in use)" );
612 
613  list.Add( Line );
614  jj++;
615  }
616  }
617 
618  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
619  wxCHOICEDLG_STYLE & ~wxCANCEL );
620 
621  dlg.ShowModal();
622 }
623 
624 
626 {
627  auto remapping = GetImagesList()->SortImagesByZOrder();
628 
630  syncLayerBox( true );
631 
632  std::unordered_map<int, int> view_remapping;
633 
634  for( auto it : remapping )
635  {
636  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
637  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
638  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
639  }
640 
641  GetGalCanvas()->GetView()->ReorderLayerData( view_remapping );
642  GetCanvas()->Refresh();
643 }
644 
645 
647 {
648  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
649  aOptions.m_DisplayFlashedItemsFill );
650  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
651  aOptions.m_DisplayLinesFill );
652  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
653  aOptions.m_DisplayPolygonsFill );
654 
655  m_DisplayOptions = aOptions;
656 
658 
659  auto view = GetGalCanvas()->GetView();
660 
661  if( update_flashed )
662  {
664  []( KIGFX::VIEW_ITEM* aItem ) {
665  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
666 
667  switch( item->m_Shape )
668  {
669  case GBR_SPOT_CIRCLE:
670  case GBR_SPOT_RECT:
671  case GBR_SPOT_OVAL:
672  case GBR_SPOT_POLY:
673  case GBR_SPOT_MACRO:
674  return true;
675 
676  default:
677  return false;
678  }
679  } );
680  }
681  else if( update_lines )
682  {
683  view->UpdateAllItemsConditionally( KIGFX::REPAINT,
684  []( KIGFX::VIEW_ITEM* aItem ) {
685  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
686 
687  switch( item->m_Shape )
688  {
689  case GBR_CIRCLE:
690  case GBR_ARC:
691  case GBR_SEGMENT:
692  return true;
693 
694  default:
695  return false;
696  }
697  } );
698  }
699  else if( update_polygons )
700  {
701  view->UpdateAllItemsConditionally( KIGFX::REPAINT,
702  []( KIGFX::VIEW_ITEM* aItem ) {
703  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
704 
705  return ( item->m_Shape == GBR_POLYGON );
706  } );
707  }
708 
709  view->UpdateAllItems( KIGFX::COLOR );
710 
711  m_canvas->Refresh( true );
712 }
713 
714 
716 {
718 
719  // Display the gerber filename
720  if( gerber == NULL )
721  {
722  SetTitle( "GerbView" );
723 
724  SetStatusText( wxEmptyString, 0 );
725 
726  wxString info;
727  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
728  m_TextInfo->SetValue( info );
729 
730  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
731  m_auimgr.Update();
732 
733  ClearMsgPanel();
734  return;
735  }
736  else
737  {
738  wxString title;
739  title.Printf( _( "GerbView" ) + wxT( " \u2014 %s%s" ),
740  gerber->m_FileName,
741  gerber->m_IsX2_file ? _( " (with X2 attributes)" )
742  : wxString( wxEmptyString ) );
743  SetTitle( title );
744 
745  gerber->DisplayImageInfo( this );
746 
747  // Display Image Name and Layer Name (from the current gerber data):
748  wxString status;
749  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
750  gerber->m_ImageName,
751  gerber->GetLayerParams().m_LayerName );
752  SetStatusText( status, 0 );
753 
754  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
755  wxString info;
756  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
757  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
758  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
759  gerber->m_FmtScale.x,
760  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
761  gerber->m_FmtScale.y,
762  gerber->m_NoTrailingZeros ? 'T' : 'L' );
763 
764  if( gerber->m_IsX2_file )
765  info << wxT(" ") << _( "X2 attr" );
766 
767  m_TextInfo->SetValue( info );
768 
769  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
770  m_auimgr.Update();
771  }
772 }
773 
774 
775 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
776 {
777  switch( aLayerID )
778  {
779  case LAYER_DCODES:
781 
784 
785  case LAYER_GERBVIEW_GRID:
786  return IsGridVisible();
787 
788  case LAYER_WORKSHEET:
790 
792  return true;
793 
794  default:
795  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aLayerID );
796  }
797 
798  return true;
799 }
800 
801 
803 {
804  long layerMask = 0;
805 
806  if( auto canvas = GetGalCanvas() )
807  {
808  // NOTE: This assumes max 32 drawlayers!
809  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
810  {
811  if( canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) )
812  layerMask |= ( 1 << i );
813  }
814 
815  return layerMask;
816  }
817  else
818  {
819  return -1;
820  }
821 }
822 
823 
824 void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask )
825 {
826  if( auto canvas = GetGalCanvas() )
827  {
828  // NOTE: This assumes max 32 drawlayers!
829  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
830  {
831  bool v = ( aLayerMask & ( 1 << i ) );
832  int layer = GERBER_DRAW_LAYER( i );
833  canvas->GetView()->SetLayerVisible( layer, v );
834  canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
836  }
837  }
838 }
839 
840 
841 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
842 {
843  return m_LayersManager->IsLayerVisible( aLayer );
844 }
845 
846 
848 {
849  COLOR4D color = COLOR4D::UNSPECIFIED;
850 
851  switch( aLayerID )
852  {
854  case LAYER_DCODES:
855  case LAYER_WORKSHEET:
857  color = m_colorsSettings->GetItemColor( aLayerID );
858  break;
859 
860  case LAYER_GERBVIEW_GRID:
861  color = GetGridColor();
862  break;
863 
864  default:
865  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ), aLayerID );
866  }
867 
868  return color;
869 }
870 
871 
873 {
876 }
877 
878 
880 {
881  switch( aLayerID )
882  {
884  case LAYER_DCODES:
885  case LAYER_WORKSHEET:
886  m_colorsSettings->SetItemColor( aLayerID, aColor );
887  break;
888 
889  case LAYER_GERBVIEW_GRID:
890  SetGridColor( aColor );
891  m_colorsSettings->SetItemColor( aLayerID, aColor );
892  break;
893 
895  SetDrawBgColor( aColor );
896  m_colorsSettings->SetItemColor( aLayerID, aColor );
897  break;
898 
899  default:
900  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ), aLayerID );
901  }
902 }
903 
905 {
908  else
909  return GetDrawBgColor();
910 }
911 
912 
914 {
915  return m_colorsSettings->GetLayerColor( aLayer );
916 }
917 
918 
919 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
920 {
921  m_colorsSettings->SetLayerColor( aLayer, aColor );
923 }
924 
925 
927 {
928  return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
929 }
930 
931 
932 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
933 {
934  ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
935 
936  if( doLayerWidgetUpdate )
938 
940 
941  if( IsGalCanvasActive() )
942  {
943  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
944  GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
945 
947 
948  GetGalCanvas()->Refresh();
949  }
950 }
951 
952 
953 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
954 {
955  m_paper = aPageSettings;
956  GBR_SCREEN* screen = static_cast<GBR_SCREEN*>( GetScreen() );
957 
958  if( screen )
959  screen->InitDataPoints( aPageSettings.GetSizeIU() );
960 
961  if( IsGalCanvasActive() )
962  {
963  auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetGalCanvas() );
964 
965  // Prepare worksheet template
966  auto worksheet =
968 
969  if( screen != NULL )
970  {
971  worksheet->SetSheetNumber( 1 );
972  worksheet->SetSheetCount( 1 );
973  }
974 
975  // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
976  drawPanel->SetWorksheet( worksheet );
977  }
978 }
979 
980 
982 {
983  return m_paper;
984 }
985 
986 
987 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
988 {
989  // this function is only needed because EDA_DRAW_FRAME is not compiled
990  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
991  // into an application specific source file.
992  return GetPageSettings().GetSizeIU();
993 }
994 
995 
997 {
998  wxASSERT( m_gerberLayout );
999  return m_gerberLayout->GetTitleBlock();
1000 }
1001 
1002 
1003 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
1004 {
1005  wxASSERT( m_gerberLayout );
1006  m_gerberLayout->SetTitleBlock( aTitleBlock );
1007 }
1008 
1009 
1011 {
1012  wxASSERT( m_gerberLayout );
1013  return m_gerberLayout->GetAuxOrigin();
1014 }
1015 
1016 
1017 void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
1018 {
1019  wxASSERT( m_gerberLayout );
1020  m_gerberLayout->SetAuxOrigin( aPosition );
1021 }
1022 
1023 
1024 void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
1025 {
1026  GetScreen()->SetCurItem( aItem );
1027 
1028  if( aItem )
1029  {
1030  if( aDisplayInfo )
1031  {
1032  MSG_PANEL_ITEMS items;
1033  aItem->GetMsgPanelInfo( m_UserUnits, items );
1034  SetMsgPanel( items );
1035  }
1036  }
1037  else
1038  {
1039  EraseMsgBox();
1040  }
1041 }
1042 
1043 
1045 {
1046  if( IsGalCanvasActive() )
1047  GetGalCanvas()->GetGAL()->SetGridColor( aColor );
1048 
1049  m_gridColor = aColor;
1050 }
1051 
1052 
1054 {
1056  return GetGerberLayout()->GetBoundingBox();
1057 }
1058 
1059 
1061 {
1063 
1064  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
1065 
1066  if( !screen )
1067  return;
1068 
1069  int dx;
1070  int dy;
1071  double dXpos;
1072  double dYpos;
1073  wxString line;
1074 
1075  if( m_DisplayOptions.m_DisplayPolarCood ) // display relative polar coordinates
1076  {
1077  double theta, ro;
1078 
1079  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1080  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1081 
1082  // atan2 in the 0,0 case returns 0
1083  theta = RAD2DEG( atan2( (double) -dy, (double) dx ) );
1084 
1085  ro = hypot( dx, dy );
1086  wxString formatter;
1087  switch( GetUserUnits() )
1088  {
1089  case INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
1090  case MILLIMETRES: formatter = wxT( "r %.5f theta %.1f" ); break;
1091  case UNSCALED_UNITS: formatter = wxT( "r %f theta %f" ); break;
1092  case DEGREES: wxASSERT( false ); break;
1093  }
1094 
1095  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
1096 
1097  SetStatusText( line, 3 );
1098  }
1099 
1100  // Display absolute coordinates:
1103 
1104  wxString absformatter;
1105  wxString relformatter;
1106 
1107  switch( GetUserUnits() )
1108  {
1109  case INCHES:
1110  absformatter = wxT( "X %.6f Y %.6f" );
1111  relformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1112  break;
1113 
1114  case MILLIMETRES:
1115  absformatter = wxT( "X %.5f Y %.5f" );
1116  relformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1117  break;
1118 
1119  case UNSCALED_UNITS:
1120  absformatter = wxT( "X %f Y %f" );
1121  relformatter = wxT( "dx %f dy %f dist %f" );
1122  break;
1123 
1124  case DEGREES:
1125  wxASSERT( false );
1126  break;
1127  }
1128 
1129  line.Printf( absformatter, dXpos, dYpos );
1130  SetStatusText( line, 2 );
1131 
1132  if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates
1133  {
1134  // Display relative coordinates:
1135  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1136  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1137  dXpos = To_User_Unit( GetUserUnits(), dx );
1138  dYpos = To_User_Unit( GetUserUnits(), dy );
1139 
1140  // We already decided the formatter above
1141  line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1142  SetStatusText( line, 3 );
1143  }
1144 }
1145 
1146 
1148 {
1150 }
1151 
1152 
1154 {
1155  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1156 }
1157 
1158 
1160 {
1162 }
1163 
1164 
1166 { // Called on units change (see EDA_DRAW_FRAME)
1170 }
1171 
1172 
1173 void GERBVIEW_FRAME::UseGalCanvas( bool aEnable )
1174 {
1175  EDA_DRAW_FRAME::UseGalCanvas( aEnable );
1176 
1177  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1178 
1179  if( m_toolManager )
1181  GetGalCanvas()->GetViewControls(), this );
1182 
1183  if( aEnable )
1184  {
1185  if( m_toolManager )
1187 
1188  m_colorsSettings->SetLegacyMode( false );
1189 
1191 
1193 
1194  galCanvas->GetView()->RecacheAllItems();
1195  galCanvas->SetEventDispatcher( m_toolDispatcher );
1196  galCanvas->StartDrawing();
1197  }
1198  else
1199  {
1200  if( m_toolManager )
1202 
1203  galCanvas->StopDrawing();
1204 
1205  // Redirect all events to the legacy canvas
1206  galCanvas->SetEventDispatcher( NULL );
1207 
1209  m_canvas->Refresh();
1210  }
1211 
1214 
1216  ReCreateMenuBar();
1217 }
1218 
1219 
1221 {
1222  // Create the manager and dispatcher & route draw panel events to the dispatcher
1225  GetGalCanvas()->GetViewControls(), this );
1226  m_actions = new GERBVIEW_ACTIONS();
1228 
1229  // Register tools
1232 
1233  // Run the selection tool, it is supposed to be always active
1234  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1235 }
1236 
1237 
1239 {
1240  UpdateStatusBar();
1241  DisplayUnitsMsg();
1242 
1243  if( m_gridSelectBox == NULL )
1244  return;
1245 
1246  // Update grid values with the current units setting.
1247  m_gridSelectBox->Clear();
1248  wxArrayString gridsList;
1249  int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1250 
1251  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
1252  {
1253  GRID_TYPE& grid = GetScreen()->GetGrid( i );
1254  m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
1255  }
1256 
1257  m_gridSelectBox->SetSelection( icurr );
1258 }
1259 
1260 
1262 {
1263  if( m_zoomSelectBox == NULL )
1264  return;
1265 
1266  wxString msg;
1267 
1268  m_zoomSelectBox->Clear();
1269  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
1270  m_zoomSelectBox->SetSelection( 0 );
1271 
1272  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
1273  {
1274  msg = _( "Zoom " );
1275 
1276  double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
1277  wxString value = wxString::Format( wxT( "%.2f" ), level );
1278  msg += value;
1279 
1280  m_zoomSelectBox->Append( msg );
1281 
1282  if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
1283  m_zoomSelectBox->SetSelection( i + 1 );
1284  }
1285 }
1286 
1287 
1288 void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
1289 {
1290  if( m_zoomSelectBox == NULL || m_auxiliaryToolBar == NULL )
1291  return;
1292 
1293  int current = 0; // display Auto if no match found
1294 
1295  // check for a match within 1%
1296  double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom();
1297 
1298  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
1299  {
1300  if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
1301  {
1302  current = i + 1;
1303  break;
1304  }
1305  }
1306 
1307  if( current != m_zoomSelectBox->GetSelection() )
1308  m_zoomSelectBox->SetSelection( current );
1309 }
1310 
1311 
1313 {
1315 
1316  ReCreateHToolbar();
1319  Layout();
1320  SendSizeEvent();
1321 }
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:125
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)
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
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...
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox.
Definition: gbr_layout.h:104
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:1448
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:388
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()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:939
bool m_showAxis
True shows the X and Y axis indicators.
Definition: draw_frame.h:133
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
void UpdateStatusBar() override
Update the status bar information.
void DeleteAllImages()
remove all loaded data in list, and delete all images.
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:126
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
virtual void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:181
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
void SetAuxOrigin(const wxPoint &aPoint) override
COLOR4D GetVisibleElementColor(int aLayerID)
Function GetVisibleElementColor returns the color of a gerber visible element.
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
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
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
const wxPoint & GetAuxOrigin() const
Definition: gbr_layout.h:74
FILE_HISTORY m_jobFileHistory
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:667
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1392
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
virtual void SetDrawBgColor(COLOR4D aColor)
Definition: draw_frame.h:380
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void SetAuxOrigin(const wxPoint &aPosition)
Definition: gbr_layout.h:79
void SetDCodeSelection(int aDCodeId)
Function SetDCodeSelection.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
static const wxString cfgShowNegativeObjects(wxT("ShowNegativeObjectsOpt"))
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer.
void SetGalCanvas(EDA_DRAW_PANEL_GAL *aPanel)
Definition: draw_frame.h:922
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
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...
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
int GetActiveLayer()
Function SetActiveLayer returns the active layer.
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
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:40
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
wxChoice * m_gridSelectBox
Definition: draw_frame.h:148
COLOR4D m_gridColor
Grid color.
Definition: draw_frame.h:112
virtual void UseGalCanvas(bool aEnable)
Use to switch between standard and GAL-based canvas.
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings 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...
EDA_RECT ComputeBoundingBox() const
Function ComputeBoundingBox calculates the bounding box containing all Gerber items.
Definition: gbr_layout.cpp:56
virtual bool IsGridVisible() const
Definition: draw_frame.h:528
wxChoice * m_SelNetnameBox
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
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 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.
FILE_HISTORY m_zipFileHistory
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
#define GERBER_DCODE_LAYER(x)
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:72
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
Class TOOL_MANAGER.
Definition: tool_manager.h:49
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board...
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...
wxAuiToolBar * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window...
Definition: draw_frame.h:153
#define DEFAULT_FILE_HISTORY_SIZE
The default file history size is 9.
Definition: pgm_base.h:58
Item is being added to the view.
Definition: view_item.h:60
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:397
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Updates the display options and refreshes the view as needed.
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:160
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:126
unsigned ImagesMaxCount() const
The max number of file images.
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:375
PAGE_INFO m_paper
void ReCreateAuxiliaryToolbar() override
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:105
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
#define GERBER_DRAWLAYERS_COUNT
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:417
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
bool GetLayerPolarity() const
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:1108
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:163
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
double To_User_Unit(EDA_UNITS_T aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:93
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:143
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
Definition: common.h:160
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:149
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 std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:84
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.
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:51
GBR_LAYOUT * m_gerberLayout
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:914
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:703
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.
FILE_HISTORY m_drillFileHistory
Class GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
int m_LastGridSizeId
Definition: draw_frame.h:107
virtual COLOR4D GetGridColor()
Definition: draw_frame.h:545
#define GERBVIEW_FRAME_NAME
Class GERBVIEW_FRAME is the main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
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.
#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...
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
void ReCreateOptToolbar()
Create or update the left vertical toolbar (option toolbar.
Class TOOL_DISPATCHER.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE ...
Definition: dcode.h:105
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
const PAGE_INFO & GetPageSettings() const override
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id...
void SetMaxFiles(size_t aMaxFiles)
Definition: pgm_base.cpp:79
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:115
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 Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:45
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools...
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:50
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
size_t i
Definition: json11.cpp:597
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[]
#define IU_PER_MILS
Definition: plotter.cpp:134
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
void SetLegacyMode(bool aMode)
Enables or disables legacy color mode.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:921
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual void SetGridVisibility(bool aVisible)
It may be overloaded by derived classes.
Definition: draw_frame.h:537
#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()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
int m_CmdId
Definition: base_screen.h:48
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...
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:120
ACTIONS * m_actions
Definition: draw_frame.h:127
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()
Update the status bar information.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void Liste_D_Codes()
Set Size Items (Lines, Flashes) from DCodes List.
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 ClearMsgPanel(void)
Clear all messages from the message panel.
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:146
static const wxString cfgShowPageSizeOption(wxT("PageSizeOpt"))
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
const std::string DrillFileExtension
void CommonSettingsChanged() override
Called after the preferences dialog is run.
#define min(a, b)
Definition: auxiliary.h:85
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:89
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
bool IsElementVisible(int aLayerID) const
Function IsElementVisible tests whether a given element category is visible.