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/editor_conditions.h>
49 #include <tool/zoom_tool.h>
50 #include <tools/gerbview_actions.h>
53 #include <tools/gerbview_control.h>
54 #include <view/view.h>
55 #include <base_screen.h>
56 #include <gerbview_painter.h>
57 #include <widgets/paged_dialog.h>
60 #include <panel_hotkeys_editor.h>
61 #include <wx/wupdlock.h>
62 
63 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
64  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
66  m_activeLayer( 0 ),
68  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
70  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
72  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
73  m_TextInfo( nullptr )
74 {
75  m_gerberLayout = nullptr;
77  m_showBorderAndTitleBlock = false; // true for reference drawings.
78  m_SelLayerBox = nullptr;
79  m_DCodeSelector = nullptr;
80  m_SelComponentBox = nullptr;
81  m_SelNetnameBox = nullptr;
82  m_SelAperAttributesBox = nullptr;
83  m_cmpText = nullptr;
84  m_netText = nullptr;
85  m_apertText = nullptr;
86  m_dcodeText = nullptr;
87  m_displayMode = 0;
88  m_AboutTitle = "GerbView";
89 
90  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
91  // some methods in code and avoid link errors
92 
93  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
94  m_drillFileHistory.SetMaxFiles( fileHistorySize );
95  m_zipFileHistory.SetMaxFiles( fileHistorySize );
96  m_jobFileHistory.SetMaxFiles( fileHistorySize );
97 
98  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
101 
102  SetCanvas( galCanvas );
103 
104  // GerbView requires draw priority for rendering negative objects
105  galCanvas->GetView()->UseDrawPriority( true );
106 
107  // Give an icon
108  wxIcon icon;
109  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
110  SetIcon( icon );
111 
112  // Be sure a page info is set. this default value will be overwritten later.
113  PAGE_INFO pageInfo( wxT( "GERBER" ) );
114  SetLayout( new GBR_LAYOUT() );
115  SetPageSettings( pageInfo );
116 
117  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
118 
119  SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) );
120 
121  // Create the PCB_LAYER_WIDGET *after* SetLayout():
123 
124  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
125  // initialize parameters in m_LayersManager
126  LoadSettings( config() );
127 
128  setupTools();
130  ReCreateMenuBar();
134 
135  m_auimgr.SetManagedWindow( this );
136 
137  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
138  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
139  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
140 
141  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
142  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
143  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
144  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
145 
146  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
147 
148  ReFillLayerWidget(); // this is near end because contents establish size
149  m_auimgr.Update();
150 
151  SetActiveLayer( 0, true );
153 
155 
156  // Nudge user to switch to OpenGL if they are on legacy or Cairo
157  if( m_firstRunDialogSetting < 1 )
158  {
159  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
160  {
161  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
162  "and faster experience. This option is turned off by "
163  "default since it is not compatible with all computers.\n\n"
164  "Would you like to try enabling graphics acceleration?\n\n"
165  "If you'd like to choose later, select Accelerated Graphics "
166  "in the Preferences menu." );
167 
168  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
169 
170  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
171 
172  if( dlg.ShowModal() == wxID_YES )
173  {
174  // Save Cairo as default in case OpenGL crashes
176 
177  // Switch to OpenGL, which will save the new setting if successful
179 
180  // Switch back to Cairo if OpenGL is not supported
181  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
183  }
184  else
185  {
186  // If they were on legacy, switch to Cairo
188  }
189  }
190 
192  SaveSettings( config() );
193  }
194 
195  SwitchCanvas( canvasType );
196 
197  // Enable the axes to match legacy draw style
198  auto& galOptions = GetGalDisplayOptions();
199  galOptions.m_axesEnabled = true;
200  galOptions.NotifyChanged();
201 
203  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
204 
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 
226 {
227  // No more vetos
228  m_isClosing = true;
229  GetCanvas()->StopDrawing();
230  GetCanvas()->GetView()->Clear();
231 
232  if( m_toolManager )
234 
235  // Be sure any OpenGL event cannot be fired after frame deletion:
236  GetCanvas()->SetEvtHandlerEnabled( false );
237 
238  Destroy();
239 }
240 
241 
242 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
243 {
244  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
245  // when trying to change the view if it is not fully initialized.
246  // It happens when starting Gerbview with a gerber job file to load
247  if( !IsShown() )
248  Show();
249 
250  // The current project path is also a valid command parameter. Check if a single path
251  // rather than a file name was passed to GerbView and use it as the initial MRU path.
252  if( aFileSet.size() > 0 )
253  {
254  wxString path = aFileSet[0];
255 
256  // For some reason wxApp appears to leave the trailing double quote on quoted
257  // parameters which are required for paths with spaces. Maybe this should be
258  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
259  // We can't buy a break!
260  if( path.Last() == wxChar( '\"' ) )
261  path.RemoveLast();
262 
263  if( !wxFileExists( path ) && wxDirExists( path ) )
264  {
265  m_mruPath = path;
266  return true;
267  }
268 
269  const unsigned limit = std::min( unsigned( aFileSet.size() ),
270  unsigned( GERBER_DRAWLAYERS_COUNT ) );
271 
272  int layer = 0;
273 
274  for( unsigned i = 0; i < limit; ++i, ++layer )
275  {
276  SetActiveLayer( layer );
277 
278  // Try to guess the type of file by its ext
279  // if it is .drl (Kicad files), .nc or .xnc it is a drill file
280  wxFileName fn( aFileSet[i] );
281  wxString ext = fn.GetExt();
282 
283  if( ext == DrillFileExtension || // our Excellon format
284  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
285  LoadExcellonFiles( aFileSet[i] );
286  else if( ext == GerberJobFileExtension )
287  LoadGerberJobFile( aFileSet[i] );
288  else
289  LoadGerberFiles( aFileSet[i] );
290  }
291  }
292 
293  Zoom_Automatique( true ); // Zoom fit in frame
294 
295  return true;
296 }
297 
298 
300 {
302 
303  if( aCfg->m_Window.grid.sizes.empty() )
304  {
305  aCfg->m_Window.grid.sizes = { "100 mil",
306  "50 mil",
307  "25 mil",
308  "20 mil",
309  "10 mil",
310  "5 mil",
311  "2.5 mil",
312  "2 mil",
313  "1 mil",
314  "0.5 mil",
315  "0.2 mil",
316  "0.1 mil",
317  "5.0 mm",
318  "2.5 mm",
319  "1.0 mm",
320  "0.5 mm",
321  "0.25 mm",
322  "0.2 mm",
323  "0.1 mm",
324  "0.05 mm",
325  "0.025 mm",
326  "0.01 mm" };
327  }
328 
329  if( aCfg->m_Window.zoom_factors.empty() )
330  {
331  aCfg->m_Window.zoom_factors = { 0.022,
332  0.035,
333  0.05,
334  0.08,
335  0.13,
336  0.22,
337  0.35,
338  0.6,
339  1.0,
340  2.2,
341  3.5,
342  5.0,
343  8.0,
344  13.0,
345  22.0,
346  35.0,
347  50.0,
348  80.0,
349  130.0,
350  220.0 };
351  }
352 
353  for( double& factor : aCfg->m_Window.zoom_factors )
354  factor = std::min( factor, MAX_ZOOM_FACTOR );
355 
356  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
357  wxCHECK( cfg, /*void*/ );
358 
360 
361  PAGE_INFO pageInfo( wxT( "GERBER" ) );
362  pageInfo.SetType( cfg->m_Appearance.page_type );
363  SetPageSettings( pageInfo );
364 
367 
371 }
372 
373 
375 {
377 
378  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
379  wxCHECK( cfg, /*void*/ );
380 
385 
389 
390  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
391  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
392 }
393 
394 
396 {
397  wxWindowUpdateLocker no_update( m_LayersManager );
398 
402 
403  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
404  wxSize bestz = m_LayersManager->GetBestSize();
405  bestz.x += 5; // gives a little margin
406 
407  lyrs.MinSize( bestz );
408  lyrs.BestSize( bestz );
409  lyrs.FloatingSize( bestz );
410 
411  if( lyrs.IsDocked() )
412  m_auimgr.Update();
413  else
414  m_LayersManager->SetSize( bestz );
415 
416  syncLayerWidget();
417 }
418 
419 
420 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
421 {
422  bool dcodes_changed = false;
423 
424  switch( aLayerID )
425  {
426  case LAYER_DCODES:
427  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
428  m_DisplayOptions.m_DisplayDCodes = aNewState;
429  break;
430 
432  {
434 
435  auto view = GetCanvas()->GetView();
436 
438  {
439  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
440 
441  // GetLayerPolarity() returns true for negative items
442  return ( item && item->GetLayerPolarity() );
443  } );
444  break;
445  }
446 
448  m_showBorderAndTitleBlock = aNewState;
449  // NOTE: LAYER_WORKSHEET always used for visibility, but the layer manager passes
450  // LAYER_GERBVIEW_WORKSHEET because of independent color control
451  GetCanvas()->GetView()->SetLayerVisible( LAYER_WORKSHEET, aNewState );
452  break;
453 
454  case LAYER_GERBVIEW_GRID:
455  SetGridVisibility( aNewState );
456  break;
457 
458  default:
459  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d",
460  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  wxFileName filename( gerber->m_FileName );
718 
719  title.Printf( wxT( "%s%s \u2014 " ) + _( "GerbView" ),
720  filename.GetFullName(),
721  gerber->m_IsX2_file ? _( " (with X2 attributes)" )
722  : wxString( wxEmptyString ) );
723  SetTitle( title );
724 
725  gerber->DisplayImageInfo( this );
726 
727  // Display Image Name and Layer Name (from the current gerber data):
728  wxString status;
729  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
730  gerber->m_ImageName,
731  gerber->GetLayerParams().m_LayerName );
732  SetStatusText( status, 0 );
733 
734  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
735  wxString info;
736  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
737  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
738  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
739  gerber->m_FmtScale.x,
740  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
741  gerber->m_FmtScale.y,
742  gerber->m_NoTrailingZeros ? 'T' : 'L' );
743 
744  if( gerber->m_IsX2_file )
745  info << wxT(" ") << _( "X2 attr" );
746 
747  m_TextInfo->SetValue( info );
748 
749  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
750  m_auimgr.Update();
751  }
752 }
753 
754 
755 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
756 {
757  switch( aLayerID )
758  {
761  case LAYER_GERBVIEW_GRID: return IsGridVisible();
763  case LAYER_GERBVIEW_BACKGROUND: return true;
764 
765  default:
766  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d", aLayerID ) );
767  }
768 
769  return true;
770 }
771 
772 
774 {
775  LSET visible = LSET::AllLayersMask();
776 
777  if( GetCanvas() )
778  {
779  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
780  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
781  }
782 
783  return visible;
784 }
785 
786 
788 {
789  if( GetCanvas() )
790  {
791  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
792  {
793  bool v = aLayerMask[i];
794  int layer = GERBER_DRAW_LAYER( i );
795  GetCanvas()->GetView()->SetLayerVisible( layer, v );
798  }
799  }
800 }
801 
802 
803 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
804 {
805  return m_LayersManager->IsLayerVisible( aLayer );
806 }
807 
808 
810 {
811  COLOR4D color = COLOR4D::UNSPECIFIED;
812  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
813 
814  switch( aLayerID )
815  {
817  case LAYER_DCODES:
820  color = settings->GetColor( aLayerID );
821  break;
822 
823  case LAYER_GERBVIEW_GRID:
824  color = GetGridColor();
825  break;
826 
827  default:
828  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d",
829  aLayerID ) );
830  }
831 
832  return color;
833 }
834 
835 
837 {
840 }
841 
842 
844 {
845  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
846 
847  switch( aLayerID )
848  {
850  case LAYER_DCODES:
851  settings->SetColor( aLayerID, aColor );
852  break;
853 
855  settings->SetColor( LAYER_GERBVIEW_WORKSHEET, aColor );
856  // LAYER_WORKSHEET color is alsu used to draw the worksheet
857  // FIX ME: why LAYER_WORKSHEET must be set, although LAYER_GERBVIEW_WORKSHEET
858  // is used to initialize the worksheet color layer.
859  settings->SetColor( LAYER_WORKSHEET, aColor );
860  break;
861 
862  case LAYER_GERBVIEW_GRID:
863  SetGridColor( aColor );
864  settings->SetColor( aLayerID, aColor );
865  break;
866 
868  SetDrawBgColor( aColor );
869  settings->SetColor( aLayerID, aColor );
870  break;
871 
872  default:
873  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d",
874  aLayerID ) );
875  }
876 }
877 
878 
880 {
883  else
884  return GetDrawBgColor();
885 }
886 
887 
889 {
890  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
891 }
892 
893 
894 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
895 {
896  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
898 }
899 
900 
901 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
902 {
903  m_activeLayer = aLayer;
904 
905  if( doLayerWidgetUpdate )
906  m_LayersManager->SelectLayer( aLayer );
907 
909 
910  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
911  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
912 
914  GetCanvas()->Refresh();
915 }
916 
917 
918 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
919 {
920  m_paper = aPageSettings;
921 
922  if( GetScreen() )
923  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
924 
925  auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
926 
927  // Prepare worksheet template
928  auto worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(),
929  &Prj(), &GetTitleBlock() );
930 
931  if( GetScreen() )
932  {
933  worksheet->SetSheetNumber( 1 );
934  worksheet->SetSheetCount( 1 );
935  }
936 
937  worksheet->SetColorLayer( LAYER_GERBVIEW_WORKSHEET );
938 
939  // Draw panel takes ownership of the worksheet
940  drawPanel->SetWorksheet( worksheet );
941 }
942 
943 
945 {
946  return m_paper;
947 }
948 
949 
950 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
951 {
952  // this function is only needed because EDA_DRAW_FRAME is not compiled
953  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
954  // into an application specific source file.
955  return GetPageSettings().GetSizeIU();
956 }
957 
958 
960 {
961  wxASSERT( m_gerberLayout );
962  return m_gerberLayout->GetTitleBlock();
963 }
964 
965 
966 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
967 {
968  wxASSERT( m_gerberLayout );
969  m_gerberLayout->SetTitleBlock( aTitleBlock );
970 }
971 
972 
974 {
975  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_GRID );
976 }
977 
978 
980 {
981  Pgm().GetSettingsManager().GetColorSettings()->SetColor( LAYER_GRID, aColor );
982  GetCanvas()->GetGAL()->SetGridColor( aColor );
983  m_gridColor = aColor;
984 }
985 
986 
987 /*
988  * Display the grid status.
989  */
991 {
992  wxString line;
993  wxString gridformatter;
994 
995  switch( m_userUnits )
996  {
997  case EDA_UNITS::INCHES: gridformatter = "grid X %.6f Y %.6f"; break;
998  case EDA_UNITS::MILLIMETRES: gridformatter = "grid X %.6f Y %.6f"; break;
999  default: gridformatter = "grid X %f Y %f"; break;
1000  }
1001 
1002  double grid_x = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x );
1003  double grid_y = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y );
1004  line.Printf( gridformatter, grid_x, grid_y );
1005 
1006  SetStatusText( line, 4 );
1007 }
1008 
1009 
1011 {
1013 
1014  if( !GetScreen() )
1015  return;
1016 
1017  wxString line;
1019 
1020  if( GetShowPolarCoords() ) // display relative polar coordinates
1021  {
1022  double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
1023  double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
1024  double theta = RAD2DEG( atan2( -dy, dx ) );
1025  double ro = hypot( dx, dy );
1026  wxString formatter;
1027 
1028  switch( GetUserUnits() )
1029  {
1030  case EDA_UNITS::INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
1031  case EDA_UNITS::MILLIMETRES: formatter = wxT( "r %.5f theta %.1f" ); break;
1032  case EDA_UNITS::UNSCALED: formatter = wxT( "r %f theta %f" ); break;
1033  default: wxASSERT( false ); break;
1034  }
1035 
1036  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
1037 
1038  SetStatusText( line, 3 );
1039  }
1040 
1041  // Display absolute coordinates:
1042  double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
1043  double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
1044 
1045  wxString absformatter;
1046  wxString relformatter;
1047 
1048  switch( GetUserUnits() )
1049  {
1050  case EDA_UNITS::INCHES:
1051  absformatter = wxT( "X %.6f Y %.6f" );
1052  relformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1053  break;
1054 
1056  absformatter = wxT( "X %.5f Y %.5f" );
1057  relformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1058  break;
1059 
1060  case EDA_UNITS::UNSCALED:
1061  absformatter = wxT( "X %f Y %f" );
1062  relformatter = wxT( "dx %f dy %f dist %f" );
1063  break;
1064 
1065  default:
1066  wxASSERT( false );
1067  break;
1068  }
1069 
1070  line.Printf( absformatter, dXpos, dYpos );
1071  SetStatusText( line, 2 );
1072 
1073  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
1074  {
1075  // Display relative coordinates:
1076  dXpos = To_User_Unit( GetUserUnits(), cursorPos.x - GetScreen()->m_LocalOrigin.x );
1077  dYpos = To_User_Unit( GetUserUnits(), cursorPos.y - GetScreen()->m_LocalOrigin.y );
1078 
1079  // We already decided the formatter above
1080  line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1081  SetStatusText( line, 3 );
1082  }
1083 
1084  DisplayGridMsg();
1085 }
1086 
1087 
1089 {
1090  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1091 }
1092 
1093 
1095 {
1097 }
1098 
1099 
1101 {
1102  // Called on units change (see EDA_DRAW_FRAME)
1106 }
1107 
1108 
1110 {
1112 
1113  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1114 
1115  if( m_toolManager )
1116  {
1118  GetCanvas()->GetViewControls(), config(), this );
1120  }
1121 
1123 
1125 
1126  galCanvas->GetView()->RecacheAllItems();
1127  galCanvas->SetEventDispatcher( m_toolDispatcher );
1128  galCanvas->StartDrawing();
1129 
1132 
1134  ReCreateMenuBar();
1135 }
1136 
1137 
1139  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1140 {
1141  wxTreebook* book = aParent->GetTreebook();
1142 
1143  book->AddPage( new wxPanel( book ), _( "Gerbview" ) );
1144  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
1145  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1146 
1147  aHotkeysPanel->AddHotKeys( GetToolManager() );
1148 }
1149 
1150 
1151 
1153 {
1154  // Create the manager and dispatcher & route draw panel events to the dispatcher
1157  GetCanvas()->GetViewControls(), config(), this );
1158  m_actions = new GERBVIEW_ACTIONS();
1160 
1161  // Register tools
1168 
1169  // Run the selection tool, it is supposed to be always active
1170  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1171 }
1172 
1173 
1175 {
1177 
1179  EDITOR_CONDITIONS cond( this );
1180 
1181  wxASSERT( mgr );
1182 
1183 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1184 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
1185 
1189 
1193 
1196 
1199 
1200 
1201  auto flashedDisplayOutlinesCond =
1202  [this] ( const SELECTION& )
1203  {
1205  };
1206 
1207  auto linesFillCond =
1208  [this] ( const SELECTION& )
1209  {
1211  };
1212 
1213  auto polygonsFilledCond =
1214  [this] ( const SELECTION& )
1215  {
1217  };
1218 
1219  auto negativeObjectsCond =
1220  [this] ( const SELECTION& )
1221  {
1223  };
1224 
1225  auto dcodeCond =
1226  [this] ( const SELECTION& )
1227  {
1228  return IsElementVisible( LAYER_DCODES );
1229  };
1230 
1231  auto diffModeCond =
1232  [this] ( const SELECTION& )
1233  {
1235  };
1236 
1237  auto highContrastModeCond =
1238  [this] ( const SELECTION& )
1239  {
1241  };
1242 
1243  auto flipGerberCond =
1244  [this] ( const SELECTION& )
1245  {
1247  };
1248 
1249  mgr->SetConditions( GERBVIEW_ACTIONS::flashedDisplayOutlines, CHECK( flashedDisplayOutlinesCond ) );
1251  mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1252  mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1253  mgr->SetConditions( GERBVIEW_ACTIONS::dcodeDisplay, CHECK( dcodeCond ) );
1254  mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
1255  mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1256  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1257 
1258 
1259  auto layersManagerShownCondition =
1260  [this] ( const SELECTION& aSel )
1261  {
1263  };
1264 
1266  CHECK( layersManagerShownCondition ) );
1267 
1268 
1269 #undef CHECK
1270 #undef ENABLE
1271 }
1272 
1273 
1274 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1275 {
1276  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1277 
1278  RecreateToolbars();
1279  Layout();
1280  SendSizeEvent();
1281 }
1282 
1283 
1285 {
1286  return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1287 }
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:1449
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.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
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
SELECTION_CONDITION FullscreenCursor()
Creates a functor testing if the cursor is full screen in a frame.
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...
static constexpr double IU_PER_MM
Mock up a conversion function.
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
static TOOL_ACTION zoomTool
Definition: actions.h:97
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:1395
double RAD2DEG(double rad)
Definition: trigo.h:220
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
Definition: filehistory.cpp:67
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Creates a functor testing if the specified tool is the current active tool in the frame.
#define MAX_ZOOM_FACTOR
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:119
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
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:162
wxString m_AboutTitle
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
virtual void RegisterUIUpdateHandler(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions) override
Register an action's update conditions with the UI layer to allow the UI to appropriately display the...
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Creates a functor testing if the specified canvas is active in the frame.
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:98
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
ACTION_MANAGER.
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
Visibility flag has changed.
Definition: view_item.h:58
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
static TOOL_ACTION imperialUnits
Definition: actions.h:142
COLOR4D m_gridColor
Class that groups generic conditions for editor states.
std::vector< double > zoom_factors
Definition: app_settings.h:86
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.
static TOOL_ACTION dcodeDisplay
static TOOL_ACTION negativeObjectDisplay
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
static TOOL_ACTION toggleDiffMode
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:50
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
#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:49
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.
static TOOL_ACTION measureTool
Definition: actions.h:150
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.
static TOOL_ACTION flipGerberView
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
bool m_DiffMode
Display layers in diff mode.
Item is being added to the view.
Definition: view_item.h:62
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.
COLOR4D GetGridColor() override
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:99
PAGE_INFO m_paper
SELECTION_CONDITION GridVisible()
Creates a functor testing if the grid is visible in a frame.
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
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:574
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:1107
static TOOL_ACTION toggleGrid
Definition: actions.h:138
GRID_SETTINGS grid
Definition: app_settings.h:89
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:43
static TOOL_ACTION linesDisplayOutlines
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)
static TOOL_ACTION togglePolarCoords
Definition: actions.h:145
ACTIONS * m_actions
Definition: tools_holder.h:51
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:756
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:388
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:705
GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied in...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void doCloseWindow() override
FILE_HISTORY m_drillFileHistory
GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
COMMON_CONTROL.
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.
SELECTION_CONDITION PolarCoordinates()
Creates a functor testing if polar coordinates are current being used.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
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:52
COMMON_TOOLS.
Definition: common_tools.h:38
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
Definition: dcode.h:105
static TOOL_ACTION flashedDisplayOutlines
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.
static TOOL_ACTION metricUnits
Definition: actions.h:143
COLOR4D GetColor(int aLayer) const
WINDOW_SETTINGS m_Window
Definition: app_settings.h:171
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:85
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:50
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
D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
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:201
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.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:199
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
static TOOL_ACTION polygonsDisplayOutlines
COLOR4D GetLayerColor(int aLayer) const
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:161
#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
bool m_FlipGerberView
Display as a mirror image.
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 LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
#define CHECK(x)
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:78
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
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.
static TOOL_ACTION highContrastMode
Definition: actions.h:101
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.
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.
static TOOL_ACTION selectionTool
Definition: actions.h:149
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:62
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:405
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)