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-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <fctsys.h>
22 #include <kiface_i.h>
23 #include <pgm_base.h>
24 #include <eda_base_frame.h>
25 #include <trigo.h>
26 #include <base_units.h>
27 #include <gbr_layer_box_selector.h>
28 #include <msgpanel.h>
29 #include <bitmaps.h>
31 #include <gerbview.h>
32 #include <gerbview_frame.h>
33 #include <gerbview_id.h>
34 #include <gerber_file_image.h>
35 #include <gerber_file_image_list.h>
36 #include <DCodeSelectionbox.h>
37 #include <gerbview_layer_widget.h>
39 #include <gerbview_settings.h>
43 #include <tool/tool_manager.h>
44 #include <tool/action_toolbar.h>
45 #include <tool/tool_dispatcher.h>
46 #include <tool/common_control.h>
47 #include <tool/common_tools.h>
48 #include <tool/zoom_tool.h>
49 #include <tools/gerbview_actions.h>
51 #include <tools/gerbview_control.h>
52 #include <view/view.h>
53 #include <base_screen.h>
54 #include <gerbview_painter.h>
55 #include <widgets/paged_dialog.h>
58 #include <panel_hotkeys_editor.h>
59 #include <wx/wupdlock.h>
60 
61 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
62  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
64  m_activeLayer( 0 ),
66  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
68  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
70  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
71  m_TextInfo( nullptr )
72 {
73  m_gerberLayout = nullptr;
75  m_showBorderAndTitleBlock = false; // true for reference drawings.
76  m_SelLayerBox = nullptr;
77  m_DCodeSelector = nullptr;
78  m_SelComponentBox = nullptr;
79  m_SelNetnameBox = nullptr;
80  m_SelAperAttributesBox = nullptr;
81  m_cmpText = nullptr;
82  m_netText = nullptr;
83  m_apertText = nullptr;
84  m_dcodeText = nullptr;
85  m_displayMode = 0;
86  m_AboutTitle = "GerbView";
87 
88  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
89  // some methods in code and avoid link errors
90 
91  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
92  m_drillFileHistory.SetMaxFiles( fileHistorySize );
93  m_zipFileHistory.SetMaxFiles( fileHistorySize );
94  m_jobFileHistory.SetMaxFiles( fileHistorySize );
95 
96  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
99 
100  SetCanvas( galCanvas );
101 
102  // GerbView requires draw priority for rendering negative objects
103  galCanvas->GetView()->UseDrawPriority( true );
104 
105  // Give an icon
106  wxIcon icon;
107  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
108  SetIcon( icon );
109 
110  // Be sure a page info is set. this default value will be overwritten later.
111  PAGE_INFO pageInfo( wxT( "GERBER" ) );
112  SetLayout( new GBR_LAYOUT() );
113  SetPageSettings( pageInfo );
114 
115  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
116 
117  SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) );
118 
119  // Create the PCB_LAYER_WIDGET *after* SetLayout():
121 
122  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
123  // initialize parameters in m_LayersManager
124  LoadSettings( config() );
125 
126  setupTools();
127  ReCreateMenuBar();
131 
132  m_auimgr.SetManagedWindow( this );
133 
134  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
135  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
136  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
137 
138  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
139  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
140  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
141  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
142 
143  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
144 
145  ReFillLayerWidget(); // this is near end because contents establish size
146  m_auimgr.Update();
147 
148  SetActiveLayer( 0, true );
150 
152 
153  // Nudge user to switch to OpenGL if they are on legacy or Cairo
154  if( m_firstRunDialogSetting < 1 )
155  {
156  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
157  {
158  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
159  "and faster experience. This option is turned off by "
160  "default since it is not compatible with all computers.\n\n"
161  "Would you like to try enabling graphics acceleration?\n\n"
162  "If you'd like to choose later, select Accelerated Graphics "
163  "in the Preferences menu." );
164 
165  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
166 
167  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
168 
169  if( dlg.ShowModal() == wxID_YES )
170  {
171  // Save Cairo as default in case OpenGL crashes
173 
174  // Switch to OpenGL, which will save the new setting if successful
176 
177  // Switch back to Cairo if OpenGL is not supported
178  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
180  }
181  else
182  {
183  // If they were on legacy, switch to Cairo
185  }
186  }
187 
189  SaveSettings( config() );
190  }
191 
192  SwitchCanvas( canvasType );
193 
194  // Enable the axes to match legacy draw style
195  auto& galOptions = GetGalDisplayOptions();
196  galOptions.m_axesEnabled = true;
197  galOptions.NotifyChanged();
198 
200  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
201 
203 
204  // Update the checked state of tools
205  SyncToolbars();
206 
207  // Ensure the window is on top
208  Raise();
209 }
210 
211 
213 {
214  // Shutdown all running tools
215  if( m_toolManager )
217 
218  GetCanvas()->GetView()->Clear();
219 
221  delete m_gerberLayout;
222 }
223 
224 
225 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
226 {
227  GetCanvas()->StopDrawing();
228  GetCanvas()->GetView()->Clear();
229 
230  if( m_toolManager )
232 
233  // Be sure any OpenGL event cannot be fired after frame deletion:
234  GetCanvas()->SetEvtHandlerEnabled( false );
235 
236  Destroy();
237 }
238 
239 
240 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
241 {
242  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
243  // when trying to change the view if it is not fully initialized.
244  // It happens when starting Gerbview with a gerber job file to load
245  if( !IsShown() )
246  Show();
247 
248  // The current project path is also a valid command parameter. Check if a single path
249  // rather than a file name was passed to GerbView and use it as the initial MRU path.
250  if( aFileSet.size() > 0 )
251  {
252  wxString path = aFileSet[0];
253 
254  // For some reason wxApp appears to leave the trailing double quote on quoted
255  // parameters which are required for paths with spaces. Maybe this should be
256  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
257  // We can't buy a break!
258  if( path.Last() == wxChar( '\"' ) )
259  path.RemoveLast();
260 
261  if( !wxFileExists( path ) && wxDirExists( path ) )
262  {
263  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
264  m_mruPath = path;
265  return true;
266  }
267 
268  const unsigned limit = std::min( unsigned( aFileSet.size() ),
269  unsigned( GERBER_DRAWLAYERS_COUNT ) );
270 
271  int layer = 0;
272 
273  for( unsigned i = 0; i < limit; ++i, ++layer )
274  {
275  SetActiveLayer( layer );
276 
277  // Try to guess the type of file by its ext
278  // if it is .drl (Kicad files), .nc or .xnc it is a drill file
279  wxFileName fn( aFileSet[i] );
280  wxString ext = fn.GetExt();
281 
282  if( ext == DrillFileExtension || // our Excellon format
283  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
284  LoadExcellonFiles( aFileSet[i] );
285  else if( ext == GerberJobFileExtension )
286  LoadGerberJobFile( aFileSet[i] );
287  else
288  LoadGerberFiles( aFileSet[i] );
289  }
290  }
291 
292  Zoom_Automatique( true ); // Zoom fit in frame
293 
294  return true;
295 }
296 
297 
299 {
301 
302  if( aCfg->m_Window.grid.sizes.empty() )
303  {
304  aCfg->m_Window.grid.sizes = { "100 mil",
305  "50 mil",
306  "25 mil",
307  "20 mil",
308  "10 mil",
309  "5 mil",
310  "2.5 mil",
311  "2 mil",
312  "1 mil",
313  "0.5 mil",
314  "0.2 mil",
315  "0.1 mil",
316  "5.0 mm",
317  "2.5 mm",
318  "1.0 mm",
319  "0.5 mm",
320  "0.25 mm",
321  "0.2 mm",
322  "0.1 mm",
323  "0.05 mm",
324  "0.025 mm",
325  "0.01 mm" };
326  }
327 
328  if( aCfg->m_Window.zoom_factors.empty() )
329  {
330  aCfg->m_Window.zoom_factors = { 0.022,
331  0.035,
332  0.05,
333  0.08,
334  0.13,
335  0.22,
336  0.35,
337  0.6,
338  1.0,
339  2.2,
340  3.5,
341  5.0,
342  8.0,
343  13.0,
344  22.0,
345  35.0,
346  50.0,
347  80.0,
348  130.0,
349  220.0 };
350  }
351 
352  for( double& factor : aCfg->m_Window.zoom_factors )
353  factor = std::min( factor, MAX_ZOOM_FACTOR );
354 
355  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
356  wxCHECK( cfg, /*void*/ );
357 
359 
360  PAGE_INFO pageInfo( wxT( "GERBER" ) );
361  pageInfo.SetType( cfg->m_Appearance.page_type );
362  SetPageSettings( pageInfo );
363 
366 
370 }
371 
372 
374 {
376 
377  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
378  wxCHECK( cfg, /*void*/ );
379 
384 
388 
389  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
390  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
391 }
392 
393 
395 {
396  wxWindowUpdateLocker no_update( m_LayersManager );
397 
401  // Update the checked state of tools
402  SyncToolbars();
403 
404  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
405  wxSize bestz = m_LayersManager->GetBestSize();
406  bestz.x += 5; // gives a little margin
407 
408  lyrs.MinSize( bestz );
409  lyrs.BestSize( bestz );
410  lyrs.FloatingSize( bestz );
411 
412  if( lyrs.IsDocked() )
413  m_auimgr.Update();
414  else
415  m_LayersManager->SetSize( bestz );
416 
417  syncLayerWidget();
418 }
419 
420 
421 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
422 {
423  bool dcodes_changed = false;
424 
425  switch( aLayerID )
426  {
427  case LAYER_DCODES:
428  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
429  m_DisplayOptions.m_DisplayDCodes = aNewState;
430  break;
431 
433  {
435 
436  auto view = GetCanvas()->GetView();
437 
439  {
440  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
441 
442  // GetLayerPolarity() returns true for negative items
443  return ( item && item->GetLayerPolarity() );
444  } );
445  break;
446  }
447 
449  m_showBorderAndTitleBlock = aNewState;
450  // NOTE: LAYER_WORKSHEET always used for visibility, but the layer manager passes
451  // LAYER_GERBVIEW_WORKSHEET because of independent color control
452  GetCanvas()->GetView()->SetLayerVisible( LAYER_WORKSHEET, aNewState );
453  break;
454 
455  case LAYER_GERBVIEW_GRID:
456  SetGridVisibility( aNewState );
457  break;
458 
459  default:
460  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aLayerID );
461  }
462 
463  if( dcodes_changed )
464  {
465  auto view = GetCanvas()->GetView();
466 
467  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
468  {
469  int layer = GERBER_DRAW_LAYER( i );
470  int dcode_layer = GERBER_DCODE_LAYER( layer );
471  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
472  }
473  }
474 
476  m_LayersManager->SetRenderState( aLayerID, aNewState );
477 }
478 
479 
481 {
482  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
483  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
486 
488 }
489 
490 
492 {
493  int layer = aLayer;
494 
495  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
496  {
497  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
498 
499  if( gerber == NULL ) // this graphic layer is available: use it
500  return layer;
501 
502  ++layer; // try next graphic layer
503 
504  if( layer >= (int)ImagesMaxCount() )
505  layer = 0;
506  }
507 
508  return NO_AVAILABLE_LAYERS;
509 }
510 
511 
513 {
515 }
516 
517 
518 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
519 {
520  if( aRebuildLayerBox )
522 
523  m_SelLayerBox->SetSelection( GetActiveLayer() );
524 
525  int dcodeSelected = -1;
527 
528  if( gerber )
529  dcodeSelected = gerber->m_Selected_Tool;
530 
531  if( m_DCodeSelector )
532  {
534  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
535  m_DCodeSelector->Enable( gerber != NULL );
536  }
537 }
538 
539 
541 {
542  int ii, jj;
543  wxString Line;
544  wxArrayString list;
545  double scale = GetUserUnits() == EDA_UNITS::INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
546  int curr_layer = GetActiveLayer();
547 
548  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
549  {
550  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
551 
552  if( gerber == NULL )
553  continue;
554 
555  if( gerber->GetDcodesCount() == 0 )
556  continue;
557 
558  if( layer == curr_layer )
559  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
560  else
561  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
562 
563  list.Add( Line );
564 
565  const char* units = GetUserUnits() == EDA_UNITS::INCHES ? "\"" : "mm";
566 
567  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
568  {
569  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
570 
571  if( pt_D_code == NULL )
572  continue;
573 
574  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
575  continue;
576 
577  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
578  jj,
579  pt_D_code->m_Num_Dcode,
580  pt_D_code->m_Size.y / scale, units,
581  pt_D_code->m_Size.x / scale, units,
582  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
583  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
584  );
585 
586  if( !pt_D_code->m_Defined )
587  Line += wxT( " (not defined)" );
588 
589  if( pt_D_code->m_InUse )
590  Line += wxT( " (in use)" );
591 
592  list.Add( Line );
593  jj++;
594  }
595  }
596 
597  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
598  wxCHOICEDLG_STYLE & ~wxCANCEL );
599 
600  dlg.ShowModal();
601 }
602 
603 
605 {
606  auto remapping = GetImagesList()->SortImagesByZOrder();
607 
609  syncLayerBox( true );
610 
611  std::unordered_map<int, int> view_remapping;
612 
613  for( auto it : remapping )
614  {
615  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
616  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
617  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
618  }
619 
620  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
621  GetCanvas()->Refresh();
622 }
623 
624 
626 {
627  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
628  aOptions.m_DisplayFlashedItemsFill );
629  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
630  aOptions.m_DisplayLinesFill );
631  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
632  aOptions.m_DisplayPolygonsFill );
633 
634  m_DisplayOptions = aOptions;
635 
637 
638  auto view = GetCanvas()->GetView();
639 
640  if( update_flashed )
641  {
643  {
644  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
645 
646  switch( item->m_Shape )
647  {
648  case GBR_SPOT_CIRCLE:
649  case GBR_SPOT_RECT:
650  case GBR_SPOT_OVAL:
651  case GBR_SPOT_POLY:
652  case GBR_SPOT_MACRO:
653  return true;
654 
655  default:
656  return false;
657  }
658  } );
659  }
660  else if( update_lines )
661  {
662  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
663  {
664  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
665 
666  switch( item->m_Shape )
667  {
668  case GBR_CIRCLE:
669  case GBR_ARC:
670  case GBR_SEGMENT:
671  return true;
672 
673  default:
674  return false;
675  }
676  } );
677  }
678  else if( update_polygons )
679  {
680  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
681  {
682  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
683 
684  return ( item->m_Shape == GBR_POLYGON );
685  } );
686  }
687 
688  view->UpdateAllItems( KIGFX::COLOR );
689  GetCanvas()->Refresh();
690 }
691 
692 
694 {
696 
697  // Display the gerber filename
698  if( gerber == NULL )
699  {
700  SetTitle( "GerbView" );
701 
702  SetStatusText( wxEmptyString, 0 );
703 
704  wxString info;
705  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
706  m_TextInfo->SetValue( info );
707 
708  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
709  m_auimgr.Update();
710 
711  ClearMsgPanel();
712  return;
713  }
714  else
715  {
716  wxString title;
717  title.Printf( _( "GerbView" ) + wxT( " \u2014 %s%s" ),
718  gerber->m_FileName,
719  gerber->m_IsX2_file ? _( " (with X2 attributes)" )
720  : wxString( wxEmptyString ) );
721  SetTitle( title );
722 
723  gerber->DisplayImageInfo( this );
724 
725  // Display Image Name and Layer Name (from the current gerber data):
726  wxString status;
727  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
728  gerber->m_ImageName,
729  gerber->GetLayerParams().m_LayerName );
730  SetStatusText( status, 0 );
731 
732  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
733  wxString info;
734  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
735  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
736  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
737  gerber->m_FmtScale.x,
738  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
739  gerber->m_FmtScale.y,
740  gerber->m_NoTrailingZeros ? 'T' : 'L' );
741 
742  if( gerber->m_IsX2_file )
743  info << wxT(" ") << _( "X2 attr" );
744 
745  m_TextInfo->SetValue( info );
746 
747  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
748  m_auimgr.Update();
749  }
750 }
751 
752 
753 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
754 {
755  switch( aLayerID )
756  {
759  case LAYER_GERBVIEW_GRID: return IsGridVisible();
761  case LAYER_GERBVIEW_BACKGROUND: return true;
762 
763  default:
764  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aLayerID );
765  }
766 
767  return true;
768 }
769 
770 
772 {
773  LSET visible = LSET::AllLayersMask();
774 
775  if( GetCanvas() )
776  {
777  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
778  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
779  }
780 
781  return visible;
782 }
783 
784 
786 {
787  if( GetCanvas() )
788  {
789  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
790  {
791  bool v = aLayerMask[i];
792  int layer = GERBER_DRAW_LAYER( i );
793  GetCanvas()->GetView()->SetLayerVisible( layer, v );
796  }
797  }
798 }
799 
800 
801 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
802 {
803  return m_LayersManager->IsLayerVisible( aLayer );
804 }
805 
806 
808 {
809  COLOR4D color = COLOR4D::UNSPECIFIED;
810 
811  switch( aLayerID )
812  {
814  case LAYER_DCODES:
817  color = Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayerID );
818  break;
819 
820  case LAYER_GERBVIEW_GRID:
821  color = GetGridColor();
822  break;
823 
824  default:
825  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ), aLayerID );
826  }
827 
828  return color;
829 }
830 
831 
833 {
836 }
837 
838 
840 {
841  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
842 
843  switch( aLayerID )
844  {
846  case LAYER_DCODES:
848  settings->SetColor( aLayerID, aColor );
849  break;
850 
851  case LAYER_GERBVIEW_GRID:
852  SetGridColor( aColor );
853  settings->SetColor( aLayerID, aColor );
854  break;
855 
857  SetDrawBgColor( aColor );
858  settings->SetColor( aLayerID, aColor );
859  break;
860 
861  default:
862  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ), aLayerID );
863  }
864 }
865 
866 
868 {
871  else
872  return GetDrawBgColor();
873 }
874 
875 
877 {
878  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
879 }
880 
881 
882 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
883 {
884  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
886 }
887 
888 
889 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
890 {
891  m_activeLayer = aLayer;
892 
893  if( doLayerWidgetUpdate )
894  m_LayersManager->SelectLayer( aLayer );
895 
897 
898  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
899  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
900 
902  GetCanvas()->Refresh();
903 }
904 
905 
906 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
907 {
908  m_paper = aPageSettings;
909 
910  if( GetScreen() )
911  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
912 
913  auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
914 
915  // Prepare worksheet template
916  auto worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(),
917  &Prj(), &GetTitleBlock() );
918 
919  if( GetScreen() )
920  {
921  worksheet->SetSheetNumber( 1 );
922  worksheet->SetSheetCount( 1 );
923  }
924 
925  worksheet->SetColorLayer( LAYER_GERBVIEW_WORKSHEET );
926 
927  // Draw panel takes ownership of the worksheet
928  drawPanel->SetWorksheet( worksheet );
929 }
930 
931 
933 {
934  return m_paper;
935 }
936 
937 
938 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
939 {
940  // this function is only needed because EDA_DRAW_FRAME is not compiled
941  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
942  // into an application specific source file.
943  return GetPageSettings().GetSizeIU();
944 }
945 
946 
948 {
949  wxASSERT( m_gerberLayout );
950  return m_gerberLayout->GetTitleBlock();
951 }
952 
953 
954 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
955 {
956  wxASSERT( m_gerberLayout );
957  m_gerberLayout->SetTitleBlock( aTitleBlock );
958 }
959 
960 
962 {
963  GetCanvas()->GetGAL()->SetGridColor( aColor );
964  m_gridColor = aColor;
965 }
966 
967 
968 /*
969  * Display the grid status.
970  */
972 {
973  wxString line;
974  wxString gridformatter;
975 
976  switch( m_userUnits )
977  {
978  case EDA_UNITS::INCHES: gridformatter = "grid X %.6f Y %.6f"; break;
979  case EDA_UNITS::MILLIMETRES: gridformatter = "grid X %.6f Y %.6f"; break;
980  default: gridformatter = "grid X %f Y %f"; break;
981  }
982 
983  double grid_x = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x );
984  double grid_y = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y );
985  line.Printf( gridformatter, grid_x, grid_y );
986 
987  SetStatusText( line, 4 );
988 }
989 
990 
992 {
994 
995  if( !GetScreen() )
996  return;
997 
998  wxString line;
1000 
1001  if( GetShowPolarCoords() ) // display relative polar coordinates
1002  {
1003  double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
1004  double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
1005  double theta = RAD2DEG( atan2( -dy, dx ) );
1006  double ro = hypot( dx, dy );
1007  wxString formatter;
1008 
1009  switch( GetUserUnits() )
1010  {
1011  case EDA_UNITS::INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
1012  case EDA_UNITS::MILLIMETRES: formatter = wxT( "r %.5f theta %.1f" ); break;
1013  case EDA_UNITS::UNSCALED: formatter = wxT( "r %f theta %f" ); break;
1014  default: wxASSERT( false ); break;
1015  }
1016 
1017  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
1018 
1019  SetStatusText( line, 3 );
1020  }
1021 
1022  // Display absolute coordinates:
1023  double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
1024  double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
1025 
1026  wxString absformatter;
1027  wxString relformatter;
1028 
1029  switch( GetUserUnits() )
1030  {
1031  case EDA_UNITS::INCHES:
1032  absformatter = wxT( "X %.6f Y %.6f" );
1033  relformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1034  break;
1035 
1037  absformatter = wxT( "X %.5f Y %.5f" );
1038  relformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1039  break;
1040 
1041  case EDA_UNITS::UNSCALED:
1042  absformatter = wxT( "X %f Y %f" );
1043  relformatter = wxT( "dx %f dy %f dist %f" );
1044  break;
1045 
1046  default:
1047  wxASSERT( false );
1048  break;
1049  }
1050 
1051  line.Printf( absformatter, dXpos, dYpos );
1052  SetStatusText( line, 2 );
1053 
1054  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
1055  {
1056  // Display relative coordinates:
1057  dXpos = To_User_Unit( GetUserUnits(), cursorPos.x - GetScreen()->m_LocalOrigin.x );
1058  dYpos = To_User_Unit( GetUserUnits(), cursorPos.y - GetScreen()->m_LocalOrigin.y );
1059 
1060  // We already decided the formatter above
1061  line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1062  SetStatusText( line, 3 );
1063  }
1064 
1065  DisplayGridMsg();
1066 }
1067 
1068 
1070 {
1071  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1072 }
1073 
1074 
1076 {
1078 }
1079 
1080 
1082 {
1083  // Called on units change (see EDA_DRAW_FRAME)
1087 }
1088 
1089 
1091 {
1093 
1094  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1095 
1096  if( m_toolManager )
1097  {
1099  GetCanvas()->GetViewControls(), config(), this );
1101  }
1102 
1104 
1106 
1107  galCanvas->GetView()->RecacheAllItems();
1108  galCanvas->SetEventDispatcher( m_toolDispatcher );
1109  galCanvas->StartDrawing();
1110 
1113 
1115  ReCreateMenuBar();
1116 
1117  // Update the checked state of tools
1118  SyncToolbars();
1119 }
1120 
1121 
1123  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1124 {
1125  wxTreebook* book = aParent->GetTreebook();
1126 
1127  book->AddPage( new wxPanel( book ), _( "Gerbview" ) );
1128  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
1129  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1130 
1131  aHotkeysPanel->AddHotKeys( GetToolManager() );
1132 }
1133 
1134 
1135 
1137 {
1138  // Create the manager and dispatcher & route draw panel events to the dispatcher
1141  GetCanvas()->GetViewControls(), config(), this );
1142  m_actions = new GERBVIEW_ACTIONS();
1144 
1145  // Register tools
1152 
1153  // Run the selection tool, it is supposed to be always active
1154  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1155 }
1156 
1157 
1158 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
1159 {
1160  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1161 
1162  RecreateToolbars();
1163  Layout();
1164  SendSizeEvent();
1165 }
1166 
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
double To_User_Unit(EDA_UNITS 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:92
GBR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
Definition: gbr_layout.h:47
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
wxString m_LayerName
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
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...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
std::vector< wxString > m_JobFileHistory
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
wxString m_mruPath
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Updates items in the view according to the given flags and condition.
Definition: view.cpp:1458
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
SETTINGS_MANAGER * GetSettingsManager() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void UpdateStatusBar() override
Update the status bar information.
void DeleteAllImages()
remove all loaded data in list, and delete all images.
ACTION_TOOLBAR * m_auxiliaryToolBar
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
Function GetNegativeItemsColor.
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
virtual void SetScreen(BASE_SCREEN *aScreen)
COLOR4D GetVisibleElementColor(int aLayerID)
Function GetVisibleElementColor returns the color of a gerber visible element.
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
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:61
std::unordered_map< int, int > SortImagesByZOrder()
Sort loaded images by Z order priority, if they have the X2 FileFormat info (SortImagesByZOrder updat...
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
double RAD2DEG(double rad)
Definition: trigo.h:215
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
Definition: filehistory.cpp:65
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE.
GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters (TODO:...
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function SetActiveLayer will change the currently active layer to aLayer and update the GERBER_LAYER_...
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:117
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of ckeck tools.
void 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:140
static TOOL_ACTION standardGraphics
Definition: actions.h:159
wxString m_AboutTitle
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
Definition: filehistory.cpp:45
void AddHotKeys(TOOL_MANAGER *aToolMgr)
const wxString & GetType() const
Definition: page_info.h:97
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Visibility flag has changed.
Definition: view_item.h:56
The base class for create windows for drawing purpose.
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
COLOR4D m_gridColor
std::vector< double > zoom_factors
Definition: app_settings.h:78
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
wxChoice * m_SelNetnameBox
void ActivateGalCanvas() override
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
void SetGridVisibility(bool aVisible) override
Function SetGridVisibility(), virtual from EDA_DRAW_FRAME It may be overloaded by derived classes.
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
GERBVIEW_ACTIONS.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
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
wxTreebook * GetTreebook()
Definition: paged_dialog.h:45
#define GERBER_DCODE_LAYER(x)
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:50
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
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.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
Item is being added to the view.
Definition: view_item.h:60
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Updates the display options and refreshes the view as needed.
LSET is a set of PCB_LAYER_IDs.
std::vector< wxString > sizes
Definition: app_settings.h:52
unsigned ImagesMaxCount() const
The max number of file images.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: common.cpp:283
std::vector< wxString > m_DrillFileHistory
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:91
PAGE_INFO m_paper
void ReCreateAuxiliaryToolbar() override
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
#define NULL
#define GERBER_DRAWLAYERS_COUNT
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
bool IsGridVisible() const
#define FIRST_DCODE
Definition: dcode.h:71
#define NO_AVAILABLE_LAYERS
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1111
GRID_SETTINGS grid
Definition: app_settings.h:81
bool LoadGerberFiles(const wxString &aFileName)
function LoadGerberFiles Load a photoplot (Gerber) file or many files.
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allows Gerbview to install its preferences panels into the preferences dialog.
SHAPE_POLY_SET.
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
bool m_showBorderAndTitleBlock
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:44
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
GBR_DISPLAY_OPTIONS m_DisplayOptions
void applyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
ACTIONS * m_actions
Definition: tools_holder.h:49
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:70
Definition of file extensions used in Kicad.
Base window classes and related definitions.
static const wxChar * ShowApertureType(APERTURE_T aType)
Function ShowApertureType returns a character string telling what type of aperture type aType is.
Definition: dcode.cpp:93
bool IsElementVisible(int aLayerID) const
Function IsElementVisible tests whether a given element category is visible.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
GBR_LAYOUT * m_gerberLayout
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:749
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:399
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:706
GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied in...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define MAX_ZOOM_FACTOR
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void OnCloseWindow(wxCloseEvent &Event)
FILE_HISTORY m_drillFileHistory
GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
COMMON_CONTROL.
virtual COLOR4D GetGridColor()
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
#define GERBVIEW_FRAME_NAME
GERBVIEW_FRAME is the main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
const BITMAP_OPAQUE icon_gerbview_xpm[1]
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
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...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:50
COMMON_TOOLS.
Definition: common_tools.h:38
TOOL_DISPATCHER.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
Definition: dcode.h:105
GBR_LAYOUT * GetGerberLayout() const
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
void DisplayGridMsg() override
Function DisplayGridMsg()
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id.
WINDOW_SETTINGS m_Window
Definition: app_settings.h:153
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:83
wxStaticText * m_cmpText
int GetActiveLayer() const
Function SetActiveLayer returns the active layer.
GERBVIEW_SELECTION_TOOL.
wxChoice * m_SelAperAttributesBox
const int scale
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
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:153
see class PGM_BASE
void LoadColors(const COLOR_SETTINGS *aSettings) override
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
std::vector< wxString > m_ZipFileHistory
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
#define DEFAULT_FILE_HISTORY_SIZE
IDs range for menuitems file history: The default range file history size is 9 (compatible with defau...
Definition: id.h:69
COLOR4D GetLayerColor(int aLayer) const
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:158
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:44
EDA_UNITS m_userUnits
#define IU_PER_MILS
Definition: plotter.cpp:138
void SetLayerColor(int aLayer, COLOR4D aColor)
wxStaticText * m_dcodeText
virtual COLOR_SETTINGS * GetColorSettings()
Returns a pointer to the active color theme settings.
virtual void SetGridColor(COLOR4D aColor) override
void syncLayerWidget()
Function syncLayerWidget updates the currently "selected" layer within the GERBER_LAYER_WIDGET.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxChoice * m_SelComponentBox
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual COLOR4D GetDrawBgColor() const
wxStaticText * m_netText
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:74
void UpdateStatusBar() override
Update the status bar information.
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
#define GERBER_DRAW_LAYER(x)
void InitTools()
Function InitTools() Initializes all registered tools.
void ReFillRender()
Function ReFillRender Rebuild Render for instance after the config is read.
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Recreates the menu bar.
wxStaticText * m_apertText
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
int getNextAvailableLayer(int aLayer=0) const
Function getNextAvailableLayer finds the next empty layer starting at aLayer and returns it to the ca...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
BASE_SCREEN class implementation.
Message panel definition file.
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
void SetLayout(GBR_LAYOUT *aLayout)
Function SetLayout sets the m_gerberLayout member in such as way as to ensure deleting any previous G...
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible tests whether a given layer is visible.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
Rendering engine changes.
Definition: tool_base.h:83
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes the row selection in the layer list to aLayer provided.
void Liste_D_Codes()
Set Size Items (Lines, Flashes) from DCodes List.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetElementVisibility(int aLayerID, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void CommonSettingsChanged(bool aEnvVarsChanged) override
Called after the preferences dialog is run.
virtual void SetGridVisibility(bool aVisible)
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers; called upon loading new gerber fil...
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
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:64
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
const std::string DrillFileExtension
PCBNEW_CONTROL.
void SetColor(int aLayer, COLOR4D aColor)
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:71
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)