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-2021 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 <kiface_base.h>
22 #include <pgm_base.h>
23 #include <eda_base_frame.h>
24 #include <base_units.h>
25 #include <bitmaps.h>
27 #include <gerbview.h>
28 #include <gerbview_frame.h>
29 #include <gerbview_id.h>
30 #include <gerber_file_image.h>
31 #include <gerber_file_image_list.h>
33 #include <gerbview_settings.h>
38 #include <tool/tool_manager.h>
39 #include <tool/action_toolbar.h>
40 #include <tool/tool_dispatcher.h>
41 #include <tool/common_control.h>
42 #include <tool/common_tools.h>
43 #include <tool/editor_conditions.h>
44 #include <tool/zoom_tool.h>
45 #include <tools/gerbview_actions.h>
49 #include <tools/gerbview_control.h>
50 #include <trigo.h>
51 #include <view/view.h>
52 #include <base_screen.h>
53 #include <gerbview_painter.h>
54 #include <widgets/msgpanel.h>
55 #include <widgets/paged_dialog.h>
59 #include <panel_hotkeys_editor.h>
60 #include <wx/wupdlock.h>
61 #include <wx/treebook.h>
62 
66 #include <zoom_defines.h>
67 
68 
69 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
70  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
72  m_TextInfo( nullptr ),
74  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
76  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
78  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
79  m_activeLayer( 0 )
80 {
81  m_maximizeByDefault = true;
82  m_gerberLayout = nullptr;
84  m_showBorderAndTitleBlock = false; // true for reference drawings.
85  m_SelLayerBox = nullptr;
86  m_DCodeSelector = nullptr;
87  m_SelComponentBox = nullptr;
88  m_SelNetnameBox = nullptr;
89  m_SelAperAttributesBox = nullptr;
90  m_cmpText = nullptr;
91  m_netText = nullptr;
92  m_apertText = nullptr;
93  m_dcodeText = nullptr;
94  m_displayMode = 0;
95  m_aboutTitle = _( "KiCad Gerber Viewer" );
96 
97  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
98  // some methods in code and avoid link errors
99 
100  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
101  m_drillFileHistory.SetMaxFiles( fileHistorySize );
102  m_zipFileHistory.SetMaxFiles( fileHistorySize );
103  m_jobFileHistory.SetMaxFiles( fileHistorySize );
104 
105  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
108 
109  SetCanvas( galCanvas );
110 
111  // GerbView requires draw priority for rendering negative objects
112  galCanvas->GetView()->UseDrawPriority( true );
113 
114  // Give an icon
115  wxIcon icon;
116  wxIconBundle icon_bundle;
117 
118  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview ) );
119  icon_bundle.AddIcon( icon );
120  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_32 ) );
121  icon_bundle.AddIcon( icon );
122  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_16 ) );
123  icon_bundle.AddIcon( icon );
124 
125  SetIcons( icon_bundle );
126 
127  // Be sure a page info is set. this default value will be overwritten later.
128  PAGE_INFO pageInfo( wxT( "GERBER" ) );
129  SetLayout( new GBR_LAYOUT() );
130  SetPageSettings( pageInfo );
131 
132  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
133 
134  SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) );
135 
136  // Create the PCB_LAYER_WIDGET *after* SetLayout():
138 
139  // Update the minimum string length in the layer panel with the length of the last default layer
140  wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(),
141  false, true );
143 
144  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
145  // initialize parameters in m_LayersManager
146  LoadSettings( config() );
147 
148  setupTools();
150  ReCreateMenuBar();
154 
155  m_auimgr.SetManagedWindow( this );
156 
157  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
158  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top()
159  .Layer(4) );
160  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom()
161  .Layer( 6 ) );
162  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left()
163  .Layer( 3 ) );
164  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right()
165  .Layer( 3 ).Caption( _( "Layers Manager" ) ).PaneBorder( false )
166  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
167 
168  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
169 
170  ReFillLayerWidget(); // this is near end because contents establish size
171  m_auimgr.Update();
172 
173  SetActiveLayer( 0, true );
175 
177 
179 
180  setupUnits( config() );
181 
182  // Enable the axes to match legacy draw style
183  auto& galOptions = GetGalDisplayOptions();
184  galOptions.m_axesEnabled = true;
185  galOptions.NotifyChanged();
186 
188  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
189 
191 
192  // Ensure the window is on top
193  Raise();
194 
195  // Register a call to update the toolbar sizes. It can't be done immediately because
196  // it seems to require some sizes calculated that aren't yet (at least on GTK).
197  CallAfter( [&]()
198  {
199  // Ensure the controls on the toolbars all are correctly sized
201  } );
202 }
203 
204 
206 {
207  // Ensure m_canvasType is up to date, to save it in config
209 
210  // Shutdown all running tools
211  if( m_toolManager )
213 
214  GetCanvas()->GetView()->Clear();
215 
217  delete m_gerberLayout;
218 }
219 
220 
222 {
223  // No more vetos
224  m_isClosing = true;
225  GetCanvas()->StopDrawing();
226  GetCanvas()->GetView()->Clear();
227 
228  if( m_toolManager )
230 
231  // Be sure any OpenGL event cannot be fired after frame deletion:
232  GetCanvas()->SetEvtHandlerEnabled( false );
233 
234  Destroy();
235 }
236 
237 
238 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
239 {
240  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
241  // when trying to change the view if it is not fully initialized.
242  // It happens when starting GerbView with a gerber job file to load
243  if( !IsShown() )
244  Show();
245 
246  // The current project path is also a valid command parameter. Check if a single path
247  // rather than a file name was passed to GerbView and use it as the initial MRU path.
248  if( aFileSet.size() > 0 )
249  {
250  wxString path = aFileSet[0];
251 
252  // For some reason wxApp appears to leave the trailing double quote on quoted
253  // parameters which are required for paths with spaces. Maybe this should be
254  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
255  // We can't buy a break!
256  if( path.Last() == wxChar( '\"' ) )
257  path.RemoveLast();
258 
259  if( !wxFileExists( path ) && wxDirExists( path ) )
260  {
261  m_mruPath = path;
262  return true;
263  }
264 
265  const unsigned limit = std::min( unsigned( aFileSet.size() ),
266  unsigned( GERBER_DRAWLAYERS_COUNT ) );
267 
268  int layer = 0;
269 
270  for( unsigned i = 0; i < limit; ++i, ++layer )
271  {
272  SetActiveLayer( layer );
273 
274  // Try to guess the type of file by its ext
275  // if it is .drl (KiCad files), .nc or .xnc it is a drill file
276  wxFileName fn( aFileSet[i] );
277  wxString ext = fn.GetExt();
278 
279  if( ext == DrillFileExtension || // our Excellon format
280  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
281  LoadExcellonFiles( aFileSet[i] );
282  else if( ext == GerberJobFileExtension )
283  LoadGerberJobFile( aFileSet[i] );
284  else
285  LoadGerberFiles( aFileSet[i] );
286  }
287  }
288 
289  Zoom_Automatique( true ); // Zoom fit in frame
290 
291  return true;
292 }
293 
294 
296 {
298 
299  if( aCfg->m_Window.grid.sizes.empty() )
300  {
301  aCfg->m_Window.grid.sizes = { "100 mil",
302  "50 mil",
303  "25 mil",
304  "20 mil",
305  "10 mil",
306  "5 mil",
307  "2.5 mil",
308  "2 mil",
309  "1 mil",
310  "0.5 mil",
311  "0.2 mil",
312  "0.1 mil",
313  "5.0 mm",
314  "2.5 mm",
315  "1.0 mm",
316  "0.5 mm",
317  "0.25 mm",
318  "0.2 mm",
319  "0.1 mm",
320  "0.05 mm",
321  "0.025 mm",
322  "0.01 mm" };
323  }
324 
325  if( aCfg->m_Window.zoom_factors.empty() )
326  {
328  }
329 
330  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
331  wxCHECK( cfg, /*void*/ );
332 
335 
336  PAGE_INFO pageInfo( wxT( "GERBER" ) );
337  pageInfo.SetType( cfg->m_Appearance.page_type );
338  SetPageSettings( pageInfo );
339 
342 
346 }
347 
348 
350 {
352 
353  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
354  wxCHECK( cfg, /*void*/ );
355 
360 
364 
365  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
366  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
367 }
368 
369 
371 {
372  wxWindowUpdateLocker no_update( m_LayersManager );
373 
377 
378  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
379  wxSize bestz = m_LayersManager->GetBestSize();
380  bestz.x += 5; // gives a little margin
381 
382  lyrs.MinSize( bestz );
383  lyrs.BestSize( bestz );
384  lyrs.FloatingSize( bestz );
385 
386  if( lyrs.IsDocked() )
387  m_auimgr.Update();
388  else
389  m_LayersManager->SetSize( bestz );
390 
391  syncLayerWidget();
392 }
393 
394 
395 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
396 {
397  bool dcodes_changed = false;
398 
399  switch( aLayerID )
400  {
401  case LAYER_DCODES:
402  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
403  m_DisplayOptions.m_DisplayDCodes = aNewState;
404  break;
405 
407  {
409 
410  auto view = GetCanvas()->GetView();
411 
413  {
414  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
415 
416  // GetLayerPolarity() returns true for negative items
417  return ( item && item->GetLayerPolarity() );
418  } );
419 
420  break;
421  }
422 
424  m_showBorderAndTitleBlock = aNewState;
425 
426  // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
427  // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
429  break;
430 
431  case LAYER_GERBVIEW_GRID:
432  SetGridVisibility( aNewState );
433  break;
434 
435  default:
436  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d",
437  aLayerID ) );
438  }
439 
440  if( dcodes_changed )
441  {
442  auto view = GetCanvas()->GetView();
443 
444  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
445  {
446  int layer = GERBER_DRAW_LAYER( i );
447  int dcode_layer = GERBER_DCODE_LAYER( layer );
448  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
449  }
450  }
451 
453  m_LayersManager->SetRenderState( aLayerID, aNewState );
454 }
455 
456 
458 {
459  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
460  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
463 
465 }
466 
467 
469 {
470  int layer = aLayer;
471 
472  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
473  {
474  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
475 
476  if( gerber == nullptr ) // this graphic layer is available: use it
477  return layer;
478 
479  ++layer; // try next graphic layer
480 
481  if( layer >= (int)ImagesMaxCount() )
482  layer = 0;
483  }
484 
485  return NO_AVAILABLE_LAYERS;
486 }
487 
488 
490 {
492 }
493 
494 
495 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
496 {
497  if( aRebuildLayerBox )
499 
500  m_SelLayerBox->SetSelection( GetActiveLayer() );
501 
502  int dcodeSelected = -1;
504 
505  if( gerber )
506  dcodeSelected = gerber->m_Selected_Tool;
507 
508  if( m_DCodeSelector )
509  {
511  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
512  m_DCodeSelector->Enable( gerber != nullptr );
513  }
514 }
515 
516 
518 {
519  auto remapping = GetImagesList()->SortImagesByZOrder();
520 
522  syncLayerBox( true );
523 
524  std::unordered_map<int, int> view_remapping;
525 
526  for( auto it : remapping )
527  {
528  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
529  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
530  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
531  }
532 
533  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
534  GetCanvas()->Refresh();
535 }
536 
538 {
539  auto target = GetCanvas()->GetBackend() == GERBVIEW_DRAW_PANEL_GAL::GAL_TYPE::GAL_TYPE_OPENGL
542  auto view = GetCanvas()->GetView();
543 
544  int lastVisibleLayer = -1;
545  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
546  {
548  // Caching doesn't work with layered rendering of diff'd layers
549  view->SetLayerTarget( GERBER_DRAW_LAYER( i ),
551  //We want the last visible layer, but deprioritize the active layer unless it's the only layer
552  if( ( lastVisibleLayer == -1 )
553  || ( view->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) && i != GetActiveLayer() ) )
554  lastVisibleLayer = i;
555  }
556 
557  //We don't want to diff the last visible layer onto the background, etc.
558  if( lastVisibleLayer != -1 )
559  {
560  view->SetLayerTarget( GERBER_DRAW_LAYER( lastVisibleLayer ), target );
561  view->SetLayerDiff( GERBER_DRAW_LAYER( lastVisibleLayer ), false );
562  }
563 
564  view->RecacheAllItems();
565  view->MarkDirty();
566  view->UpdateAllItems( KIGFX::ALL );
567 }
568 
569 
571 {
572  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
573  aOptions.m_DisplayFlashedItemsFill );
574  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
575  aOptions.m_DisplayLinesFill );
576  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
577  aOptions.m_DisplayPolygonsFill );
578  bool update_diff_mode = ( m_DisplayOptions.m_DiffMode != aOptions.m_DiffMode );
579 
580  auto view = GetCanvas()->GetView();
581 
582  m_DisplayOptions = aOptions;
583 
585 
586  if( update_diff_mode )
588 
589  if( update_flashed )
590  {
591  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
592  {
593  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
594 
595  switch( item->m_Shape )
596  {
597  case GBR_SPOT_CIRCLE:
598  case GBR_SPOT_RECT:
599  case GBR_SPOT_OVAL:
600  case GBR_SPOT_POLY:
601  case GBR_SPOT_MACRO:
602  return true;
603 
604  default:
605  return false;
606  }
607  } );
608  }
609  else if( update_lines )
610  {
611  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
612  {
613  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
614 
615  switch( item->m_Shape )
616  {
617  case GBR_CIRCLE:
618  case GBR_ARC:
619  case GBR_SEGMENT:
620  return true;
621 
622  default:
623  return false;
624  }
625  } );
626  }
627  else if( update_polygons )
628  {
629  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
630  {
631  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
632 
633  return ( item->m_Shape == GBR_POLYGON );
634  } );
635  }
636 
637  view->UpdateAllItems( KIGFX::COLOR );
638  GetCanvas()->Refresh();
639 }
640 
641 
643 {
645 
646  // Display the gerber filename
647  if( gerber == nullptr )
648  {
649  SetTitle( _("Gerber Viewer") );
650 
651  SetStatusText( wxEmptyString, 0 );
652 
653  wxString info;
654  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
655  m_TextInfo->SetValue( info );
656 
657  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
658  m_auimgr.Update();
659 
660  ClearMsgPanel();
661  return;
662  }
663  else
664  {
665  wxString title;
666  wxFileName filename( gerber->m_FileName );
667 
668  title = filename.GetFullName();
669 
670  if( gerber->m_IsX2_file )
671  title += wxS( " " ) + _( "(with X2 attributes)" );
672 
673  title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
674  SetTitle( title );
675 
676  gerber->DisplayImageInfo( this );
677 
678  // Display Image Name and Layer Name (from the current gerber data):
679  wxString status;
680  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
681  gerber->m_ImageName,
682  gerber->GetLayerParams().m_LayerName );
683  SetStatusText( status, 0 );
684 
685  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
686  wxString info;
687  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
688  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
689  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
690  gerber->m_FmtScale.x,
691  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
692  gerber->m_FmtScale.y,
693  gerber->m_NoTrailingZeros ? 'T' : 'L' );
694 
695  if( gerber->m_IsX2_file )
696  info << wxT(" ") << _( "X2 attr" );
697 
698  m_TextInfo->SetValue( info );
699 
700  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
701  m_auimgr.Update();
702  }
703 }
704 
705 
706 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
707 {
708  switch( aLayerID )
709  {
712  case LAYER_GERBVIEW_GRID: return IsGridVisible();
714  case LAYER_GERBVIEW_BACKGROUND: return true;
715 
716  default:
717  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d",
718  aLayerID ) );
719  }
720 
721  return true;
722 }
723 
724 
726 {
727  LSET visible = LSET::AllLayersMask();
728 
729  if( GetCanvas() )
730  {
731  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
732  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
733  }
734 
735  return visible;
736 }
737 
738 
740 {
741  if( GetCanvas() )
742  {
743  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
744  {
745  bool v = aLayerMask[i];
746  int layer = GERBER_DRAW_LAYER( i );
747  GetCanvas()->GetView()->SetLayerVisible( layer, v );
750  }
751  }
752 }
753 
754 
755 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
756 {
757  return m_LayersManager->IsLayerVisible( aLayer );
758 }
759 
760 
762 {
763  COLOR4D color = COLOR4D::UNSPECIFIED;
764  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
765 
766  switch( aLayerID )
767  {
769  case LAYER_DCODES:
772  color = settings->GetColor( aLayerID );
773  break;
774 
775  case LAYER_GERBVIEW_GRID:
776  color = GetGridColor();
777  break;
778 
779  default:
780  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d",
781  aLayerID ) );
782  }
783 
784  return color;
785 }
786 
787 
789 {
792 }
793 
794 
795 void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, const COLOR4D& aColor )
796 {
797  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
798 
799  switch( aLayerID )
800  {
802  case LAYER_DCODES:
803  settings->SetColor( aLayerID, aColor );
804  break;
805 
807  settings->SetColor( LAYER_GERBVIEW_DRAWINGSHEET, aColor );
808 
809  // LAYER_DRAWINGSHEET color is also used to draw the drawing-sheet
810  // FIX ME: why LAYER_DRAWINGSHEET must be set, although LAYER_GERBVIEW_DRAWINGSHEET
811  // is used to initialize the drawing-sheet color layer.
812  settings->SetColor( LAYER_DRAWINGSHEET, aColor );
813  break;
814 
815  case LAYER_GERBVIEW_GRID:
816  SetGridColor( aColor );
817  settings->SetColor( aLayerID, aColor );
818  break;
819 
821  SetDrawBgColor( aColor );
822  settings->SetColor( aLayerID, aColor );
823  break;
824 
825  default:
826  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d",
827  aLayerID ) );
828  }
829 }
830 
831 
833 {
836  else
837  return GetDrawBgColor();
838 }
839 
840 
842 {
843  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
844 }
845 
846 
847 void GERBVIEW_FRAME::SetLayerColor( int aLayer, const COLOR4D& aColor )
848 {
849  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
851 }
852 
853 
854 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
855 {
856  m_activeLayer = aLayer;
857 
860 
861  if( doLayerWidgetUpdate )
862  m_LayersManager->SelectLayer( aLayer );
863 
865 
866  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
867  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
868 
870  GetCanvas()->Refresh();
871 }
872 
873 
874 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
875 {
876  m_paper = aPageSettings;
877 
878  if( GetScreen() )
879  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
880 
881  GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
882 
883  // Prepare drawing-sheet template
885  &Prj(), &GetTitleBlock() );
886 
887  if( GetScreen() )
888  {
889  drawingSheet->SetPageNumber( "1" );
890  drawingSheet->SetSheetCount( 1 );
891  }
892 
894 
895  // Draw panel takes ownership of the drawing-sheet
896  drawPanel->SetDrawingSheet( drawingSheet );
897 }
898 
899 
901 {
902  return m_paper;
903 }
904 
905 
906 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
907 {
908  // this function is only needed because EDA_DRAW_FRAME is not compiled
909  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
910  // into an application specific source file.
911  return GetPageSettings().GetSizeIU();
912 }
913 
914 
916 {
917  wxASSERT( m_gerberLayout );
918  return m_gerberLayout->GetTitleBlock();
919 }
920 
921 
922 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
923 {
924  wxASSERT( m_gerberLayout );
925  m_gerberLayout->SetTitleBlock( aTitleBlock );
926 }
927 
928 
930 {
931  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_GRID );
932 }
933 
934 
936 {
937  Pgm().GetSettingsManager().GetColorSettings()->SetColor( LAYER_GRID, aColor );
938  GetCanvas()->GetGAL()->SetGridColor( aColor );
939  m_gridColor = aColor;
940 }
941 
942 
944 {
945  wxString line;
946 
947  line.Printf( "grid X %s Y %s",
948  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
949  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
950 
951  SetStatusText( line, 4 );
952 }
953 
954 
956 {
958 
959  if( !GetScreen() )
960  return;
961 
962  wxString line;
964 
965  if( GetShowPolarCoords() ) // display relative polar coordinates
966  {
967  double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
968  double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
969  double theta = RAD2DEG( atan2( -dy, dx ) );
970  double ro = hypot( dx, dy );
971 
972  line.Printf( wxT( "r %s theta %s" ),
973  MessageTextFromValue( GetUserUnits(), ro, false ),
974  MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) );
975 
976  SetStatusText( line, 3 );
977  }
978 
979  // Display absolute coordinates:
980  line.Printf( wxT( "X %s Y %s" ),
981  MessageTextFromValue( GetUserUnits(), cursorPos.x, false ),
982  MessageTextFromValue( GetUserUnits(), cursorPos.y, false ) );
983  SetStatusText( line, 2 );
984 
985  if( !GetShowPolarCoords() )
986  {
987  // Display relative cartesian coordinates:
988  double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
989  double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
990 
991  line.Printf( wxT( "dx %s dy %s dist %s" ),
992  MessageTextFromValue( GetUserUnits(), dXpos, false ),
993  MessageTextFromValue( GetUserUnits(), dYpos, false ),
994  MessageTextFromValue( GetUserUnits(), hypot( dXpos, dYpos ), false ) );
995  SetStatusText( line, 3 );
996  }
997 
998  DisplayGridMsg();
999 }
1000 
1001 
1003 {
1004  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1005 }
1006 
1007 
1009 {
1011 }
1012 
1013 
1015 {
1016  // Called on units change (see EDA_DRAW_FRAME)
1020 }
1021 
1022 
1024 {
1026 
1027  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1028 
1029  if( m_toolManager )
1030  {
1032  GetCanvas()->GetViewControls(), config(), this );
1034  }
1035 
1037 
1039 
1040  galCanvas->GetView()->RecacheAllItems();
1041  galCanvas->SetEventDispatcher( m_toolDispatcher );
1042  galCanvas->StartDrawing();
1043 
1046 
1048  ReCreateMenuBar();
1049 }
1050 
1051 
1053  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1054 {
1055  wxTreebook* book = aParent->GetTreebook();
1056 
1057  book->AddPage( new wxPanel( book ), _( "GerbView" ) );
1058  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ),
1059  _( "Display Options" ) );
1060  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1061  book->AddSubPage( new PANEL_GERBVIEW_EXCELLON_SETTINGS( this, book ),
1062  _( "Excellon Options" ) );
1063 
1064  aHotkeysPanel->AddHotKeys( GetToolManager() );
1065 }
1066 
1067 
1068 
1070 {
1071  // Create the manager and dispatcher & route draw panel events to the dispatcher
1074  GetCanvas()->GetViewControls(), config(), this );
1075  m_actions = new GERBVIEW_ACTIONS();
1077 
1078  // Register tools
1086 
1087  // Run the selection tool, it is supposed to be always active
1088  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1089 }
1090 
1091 
1093 {
1095 
1097  EDITOR_CONDITIONS cond( this );
1098 
1099  wxASSERT( mgr );
1100 
1101 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1102 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
1103 
1105  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
1109  CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
1110 
1114 
1116  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
1118  CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
1120  CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1121 
1122  auto flashedDisplayOutlinesCond =
1123  [this] ( const SELECTION& )
1124  {
1126  };
1127 
1128  auto linesFillCond =
1129  [this] ( const SELECTION& )
1130  {
1132  };
1133 
1134  auto polygonsFilledCond =
1135  [this] ( const SELECTION& )
1136  {
1138  };
1139 
1140  auto negativeObjectsCond =
1141  [this] ( const SELECTION& )
1142  {
1144  };
1145 
1146  auto dcodeCond =
1147  [this] ( const SELECTION& )
1148  {
1149  return IsElementVisible( LAYER_DCODES );
1150  };
1151 
1152  auto diffModeCond =
1153  [this] ( const SELECTION& )
1154  {
1156  };
1157 
1158  auto highContrastModeCond =
1159  [this] ( const SELECTION& )
1160  {
1162  };
1163 
1164  auto flipGerberCond =
1165  [this] ( const SELECTION& )
1166  {
1168  };
1169 
1170  auto layersManagerShownCondition =
1171  [this] ( const SELECTION& aSel )
1172  {
1174  };
1175 
1177  CHECK( flashedDisplayOutlinesCond ) );
1179  mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1180  mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1181  mgr->SetConditions( GERBVIEW_ACTIONS::dcodeDisplay, CHECK( dcodeCond ) );
1182  mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
1183  mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1184  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1186  CHECK( layersManagerShownCondition ) );
1187 
1188 #undef CHECK
1189 #undef ENABLE
1190 }
1191 
1192 
1193 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1194 {
1195  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1196 
1197  RecreateToolbars();
1198  Layout();
1199  SendSizeEvent();
1200 }
1201 
1202 
1204 {
1205  return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1206 }
1207 
1208 
1210 {
1212 
1213  // show/hide auxiliary Vertical layers and visibility manager toolbar
1214  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1215  m_auimgr.Update();
1216 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
A list of GERBER_DRAW_ITEM objects currently loaded.
Definition: gbr_layout.h:45
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
wxString m_LayerName
wxSize GetBestSize() const
Return the preferred minimum size, taking into consideration the dynamic content.
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
#define GERBER_DCODE_LAYER(x)
Definition: layer_ids.h:400
static TOOL_ACTION layerChanged
void SortLayersByX2Attributes()
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
virtual void SetGridColor(const COLOR4D &aColor) override
std::vector< wxString > m_JobFileHistory
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
wxString m_mruPath
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1434
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void SetLayerColor(int aLayer, const COLOR4D &aColor)
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for drawing sheet item colors.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
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, freeing the memory.
ACTION_TOOLBAR * m_auxiliaryToolBar
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
This is usually the background color, but can be another color in order to see negative objects.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
virtual void SetScreen(BASE_SCREEN *aScreen)
COLOR4D GetVisibleElementColor(int aLayerID)
Return the color of a gerber visible element.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
static TOOL_ACTION zoomTool
Definition: actions.h:99
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
FILE_HISTORY m_jobFileHistory
void SetPageSettings(const PAGE_INFO &aPageSettings) override
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
void SetVisibleElementColor(int aLayerID, const COLOR4D &aColor)
int color
Definition: DXF_plotter.cpp:57
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()
Rebuild GAL display lists.
Definition: view.cpp:1389
double RAD2DEG(double rad)
Definition: trigo.h:230
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
Definition: filehistory.cpp:67
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
Hold the image data and parameters for one gerber file and layer parameters.
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:119
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
wxSize m_FmtLen
Image rotation (0, 90, 180, 270 only) in degrees.
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
void SetDCodeSelection(int aDCodeId)
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
void SetColor(int aLayer, const COLOR4D &aColor)
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
Definition: filehistory.cpp:45
void AddHotKeys(TOOL_MANAGER *aToolMgr)
static TOOL_ACTION toggleLayerManager
const wxString & GetType() const
Definition: page_info.h:94
void SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
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
Manage TOOL_ACTION objects.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:76
Color has changed.
Definition: view_item.h:48
All except INITIAL_ADD.
Definition: view_item.h:53
The base class for create windows for drawing purpose.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
Definition: view.h:419
wxSize m_FmtScale
< Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
Class that groups generic conditions for editor states.
void SetSmallestLayerString(const wxString &aString)
Set the string that is used for determining the smallest string displayed in the layer's tab.
Definition: layer_widget.h:141
std::vector< double > zoom_factors
Definition: app_settings.h:86
void DeactivateTool()
Deactivate the currently active tool.
void UpdateDiffLayers()
Update each layers' differential option.
bool InvokeTool(TOOL_ID aToolId)
Call 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
Use to start up the GAL drawing canvas.
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
void SetGridVisibility(bool aVisible) override
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
Gather all the actions that are shared by tools.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
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.
bool m_IsX2_file
< True if a X2 gerber attribute was found in file.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=nullptr)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: ui_common.cpp:156
FILE_HISTORY m_zipFileHistory
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
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:46
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
Master controller class:
Definition: tool_manager.h:54
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:154
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)
Display information about image parameters in the status bar.
bool m_DiffMode
Display layers in diff mode.
Item needs to be redrawn.
Definition: view_item.h:52
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Update the display options and refreshes the view as needed.
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
std::vector< wxString > sizes
Definition: app_settings.h:52
unsigned ImagesMaxCount() const
The max number of file images.
COLOR4D GetGridColor() override
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()
Create 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 ...
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
bool IsGridVisible() const
#define NO_AVAILABLE_LAYERS
void Clear()
Remove all items from the view.
Definition: view.cpp:1104
static TOOL_ACTION toggleGrid
Definition: actions.h:140
GRID_SETTINGS grid
Definition: app_settings.h:89
bool LoadGerberFiles(const wxString &aFileName)
Load a given Gerber file or selected file(s), if the filename is empty.
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow Gerbview to install its preferences panels into the preferences dialog.
Represent a set of closed polygons.
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
bool m_showBorderAndTitleBlock
static TOOL_ACTION inchesUnits
Definition: actions.h:144
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
static TOOL_ACTION linesDisplayOutlines
GBR_DISPLAY_OPTIONS m_DisplayOptions
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:378
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:149
ACTIONS * m_actions
Definition: tools_holder.h:159
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:63
Definition of file extensions used in Kicad.
Base window classes and related definitions.
bool IsElementVisible(int aLayerID) const
Test whether a given element category is visible.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
GBR_LAYOUT * m_gerberLayout
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:787
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:388
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
Definition: view.cpp:675
Abstract functions of LAYER_WIDGET so they may be tied into the GERBVIEW_FRAME's data and we can add ...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define ZOOM_LIST_GERBVIEW
Definition: zoom_defines.h:29
drawingsheet frame and titleblock
Definition: layer_ids.h:213
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void doCloseWindow() override
FILE_HISTORY m_drillFileHistory
Store GerbView specific render settings.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Handle actions that are shared between different applications.
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
The main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
void StartDrawing()
Begin drawing if it was stopped previously.
SELECTION_CONDITION PolarCoordinates()
Create a functor testing if polar coordinates are current being used.
#define GERBER_DRAW_LAYER(x)
Definition: layer_ids.h:398
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...
static TOOL_ACTION milsUnits
Definition: actions.h:145
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
Handles action that are shared between different applications.
Definition: common_tools.h:37
static TOOL_ACTION flashedDisplayOutlines
GBR_LAYOUT * GetGerberLayout() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
void DisplayGridMsg() override
Display the current grid pane on the status bar.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(LAYER_NUM aLayer)
Return the visible state of the layer ROW associated with aLayer id.
void ReFill()
Rebuild Render for instance after the config is read.
COLOR4D GetColor(int aLayer) const
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
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
Return the active layer.
Selection tool for GerbView, based on the one in Pcbnew.
wxChoice * m_SelAperAttributesBox
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
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
Main rendering target (cached)
Definition: definitions.h:48
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Set or update the drawing-sheet (borders and title block) used by the draw panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void setupUnits(APP_SETTINGS_BASE *aCfg)
#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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:41
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
#define IU_PER_MILS
Definition: plotter.cpp:136
wxStaticText * m_dcodeText
bool m_FlipGerberView
Display as a mirror image.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
void syncLayerWidget()
Update 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)
Load 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...
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
bool LoadExcellonFiles(const wxString &aFileName)
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:54
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
void UpdateStatusBar() override
Update the status bar information.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
void InitTools()
Initializes all registered tools.
void 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
int getNextAvailableLayer(int aLayer=0) const
Find the next empty layer starting at aLayer and returns it to the caller.
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)
Set the state of the checkbox associated with aId within the Render tab group of the widget.
void SetLayout(GBR_LAYOUT *aLayout)
Set the m_gerberLayout member in such as way as to ensure deleting any previous GBR_LAYOUT.
bool IsLayerVisible(int aLayer) const
Test 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:103
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
Rendering engine changes.
Definition: tool_base.h:81
void SelectLayer(LAYER_NUM aLayer)
Change the row selection in the layer list to aLayer provided.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetElementVisibility(int aLayerID, bool aNewState)
Change the visibility of an element category.
const wxString GetDisplayName(int aIdx, bool aNameOnly=false, bool aFullName=false)
Get the display name for the layer at aIdx.
virtual void SetGridVisibility(bool aVisible)
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void UpdateTitleAndInfo()
Display the short filename (if exists) of the selected layer on the caption of the main GerbView wind...
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
virtual void SetDrawBgColor(const COLOR4D &aColor)
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:153
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
GERBER_LAYER & GetLayerParams()
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
const std::string DrillFileExtension
Handle actions that are shared between different frames in Pcbnew.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:405
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:64
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)