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_i.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>
58 #include <panel_hotkeys_editor.h>
59 #include <wx/wupdlock.h>
60 
64 #include <zoom_defines.h>
65 
66 
67 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
68  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
70  m_TextInfo( nullptr ),
72  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
74  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
76  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
77  m_activeLayer( 0 )
78 {
79  m_maximizeByDefault = true;
80  m_gerberLayout = nullptr;
82  m_showBorderAndTitleBlock = false; // true for reference drawings.
83  m_SelLayerBox = nullptr;
84  m_DCodeSelector = nullptr;
85  m_SelComponentBox = nullptr;
86  m_SelNetnameBox = nullptr;
87  m_SelAperAttributesBox = nullptr;
88  m_cmpText = nullptr;
89  m_netText = nullptr;
90  m_apertText = nullptr;
91  m_dcodeText = nullptr;
92  m_displayMode = 0;
93  m_aboutTitle = _( "KiCad Gerber Viewer" );
94 
95  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
96  // some methods in code and avoid link errors
97 
98  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
99  m_drillFileHistory.SetMaxFiles( fileHistorySize );
100  m_zipFileHistory.SetMaxFiles( fileHistorySize );
101  m_jobFileHistory.SetMaxFiles( fileHistorySize );
102 
103  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
106 
107  SetCanvas( galCanvas );
108 
109  // GerbView requires draw priority for rendering negative objects
110  galCanvas->GetView()->UseDrawPriority( true );
111 
112  // Give an icon
113  wxIcon icon;
114  wxIconBundle icon_bundle;
115 
116  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview ) );
117  icon_bundle.AddIcon( icon );
118  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_32 ) );
119  icon_bundle.AddIcon( icon );
120  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_16 ) );
121  icon_bundle.AddIcon( icon );
122 
123  SetIcons( icon_bundle );
124 
125  // Be sure a page info is set. this default value will be overwritten later.
126  PAGE_INFO pageInfo( wxT( "GERBER" ) );
127  SetLayout( new GBR_LAYOUT() );
128  SetPageSettings( pageInfo );
129 
130  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
131 
132  SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) );
133 
134  // Create the PCB_LAYER_WIDGET *after* SetLayout():
136 
137  // Update the minimum string length in the layer panel with the length of the last default layer
138  wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(), false, true );
140 
141  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
142  // initialize parameters in m_LayersManager
143  LoadSettings( config() );
144 
145  setupTools();
147  ReCreateMenuBar();
151 
152  m_auimgr.SetManagedWindow( this );
153 
154  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
155  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top()
156  .Layer(4) );
157  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom()
158  .Layer( 6 ) );
159  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left()
160  .Layer( 3 ) );
161  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right()
162  .Layer( 3 ).Caption( _( "Layers Manager" ) ).PaneBorder( false )
163  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
164 
165  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
166 
167  ReFillLayerWidget(); // this is near end because contents establish size
168  m_auimgr.Update();
169 
170  SetActiveLayer( 0, true );
172 
174 
176 
177  setupUnits( config() );
178 
179  // Enable the axes to match legacy draw style
180  auto& galOptions = GetGalDisplayOptions();
181  galOptions.m_axesEnabled = true;
182  galOptions.NotifyChanged();
183 
185  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
186 
188 
189  // Ensure the window is on top
190  Raise();
191 
192  // Register a call to update the toolbar sizes. It can't be done immediately because
193  // it seems to require some sizes calculated that aren't yet (at least on GTK).
194  CallAfter( [&]()
195  {
196  // Ensure the controls on the toolbars all are correctly sized
198  } );
199 }
200 
201 
203 {
204  // Shutdown all running tools
205  if( m_toolManager )
207 
208  GetCanvas()->GetView()->Clear();
209 
211  delete m_gerberLayout;
212 }
213 
214 
216 {
217  // No more vetos
218  m_isClosing = true;
219  GetCanvas()->StopDrawing();
220  GetCanvas()->GetView()->Clear();
221 
222  if( m_toolManager )
224 
225  // Be sure any OpenGL event cannot be fired after frame deletion:
226  GetCanvas()->SetEvtHandlerEnabled( false );
227 
228  Destroy();
229 }
230 
231 
232 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
233 {
234  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
235  // when trying to change the view if it is not fully initialized.
236  // It happens when starting GerbView with a gerber job file to load
237  if( !IsShown() )
238  Show();
239 
240  // The current project path is also a valid command parameter. Check if a single path
241  // rather than a file name was passed to GerbView and use it as the initial MRU path.
242  if( aFileSet.size() > 0 )
243  {
244  wxString path = aFileSet[0];
245 
246  // For some reason wxApp appears to leave the trailing double quote on quoted
247  // parameters which are required for paths with spaces. Maybe this should be
248  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
249  // We can't buy a break!
250  if( path.Last() == wxChar( '\"' ) )
251  path.RemoveLast();
252 
253  if( !wxFileExists( path ) && wxDirExists( path ) )
254  {
255  m_mruPath = path;
256  return true;
257  }
258 
259  const unsigned limit = std::min( unsigned( aFileSet.size() ),
260  unsigned( GERBER_DRAWLAYERS_COUNT ) );
261 
262  int layer = 0;
263 
264  for( unsigned i = 0; i < limit; ++i, ++layer )
265  {
266  SetActiveLayer( layer );
267 
268  // Try to guess the type of file by its ext
269  // if it is .drl (KiCad files), .nc or .xnc it is a drill file
270  wxFileName fn( aFileSet[i] );
271  wxString ext = fn.GetExt();
272 
273  if( ext == DrillFileExtension || // our Excellon format
274  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
275  LoadExcellonFiles( aFileSet[i] );
276  else if( ext == GerberJobFileExtension )
277  LoadGerberJobFile( aFileSet[i] );
278  else
279  LoadGerberFiles( aFileSet[i] );
280  }
281  }
282 
283  Zoom_Automatique( true ); // Zoom fit in frame
284 
285  return true;
286 }
287 
288 
290 {
292 
293  if( aCfg->m_Window.grid.sizes.empty() )
294  {
295  aCfg->m_Window.grid.sizes = { "100 mil",
296  "50 mil",
297  "25 mil",
298  "20 mil",
299  "10 mil",
300  "5 mil",
301  "2.5 mil",
302  "2 mil",
303  "1 mil",
304  "0.5 mil",
305  "0.2 mil",
306  "0.1 mil",
307  "5.0 mm",
308  "2.5 mm",
309  "1.0 mm",
310  "0.5 mm",
311  "0.25 mm",
312  "0.2 mm",
313  "0.1 mm",
314  "0.05 mm",
315  "0.025 mm",
316  "0.01 mm" };
317  }
318 
319  if( aCfg->m_Window.zoom_factors.empty() )
320  {
322  }
323 
324  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
325  wxCHECK( cfg, /*void*/ );
326 
328 
329  PAGE_INFO pageInfo( wxT( "GERBER" ) );
330  pageInfo.SetType( cfg->m_Appearance.page_type );
331  SetPageSettings( pageInfo );
332 
335 
339 }
340 
341 
343 {
345 
346  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
347  wxCHECK( cfg, /*void*/ );
348 
353 
357 
358  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
359  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
360 }
361 
362 
364 {
365  wxWindowUpdateLocker no_update( m_LayersManager );
366 
370 
371  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
372  wxSize bestz = m_LayersManager->GetBestSize();
373  bestz.x += 5; // gives a little margin
374 
375  lyrs.MinSize( bestz );
376  lyrs.BestSize( bestz );
377  lyrs.FloatingSize( bestz );
378 
379  if( lyrs.IsDocked() )
380  m_auimgr.Update();
381  else
382  m_LayersManager->SetSize( bestz );
383 
384  syncLayerWidget();
385 }
386 
387 
388 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
389 {
390  bool dcodes_changed = false;
391 
392  switch( aLayerID )
393  {
394  case LAYER_DCODES:
395  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
396  m_DisplayOptions.m_DisplayDCodes = aNewState;
397  break;
398 
400  {
402 
403  auto view = GetCanvas()->GetView();
404 
406  {
407  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
408 
409  // GetLayerPolarity() returns true for negative items
410  return ( item && item->GetLayerPolarity() );
411  } );
412  break;
413  }
414 
416  m_showBorderAndTitleBlock = aNewState;
417  // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
418  // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
420  break;
421 
422  case LAYER_GERBVIEW_GRID:
423  SetGridVisibility( aNewState );
424  break;
425 
426  default:
427  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d",
428  aLayerID ) );
429  }
430 
431  if( dcodes_changed )
432  {
433  auto view = GetCanvas()->GetView();
434 
435  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
436  {
437  int layer = GERBER_DRAW_LAYER( i );
438  int dcode_layer = GERBER_DCODE_LAYER( layer );
439  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
440  }
441  }
442 
444  m_LayersManager->SetRenderState( aLayerID, aNewState );
445 }
446 
447 
449 {
450  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
451  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
454 
456 }
457 
458 
460 {
461  int layer = aLayer;
462 
463  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
464  {
465  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
466 
467  if( gerber == NULL ) // this graphic layer is available: use it
468  return layer;
469 
470  ++layer; // try next graphic layer
471 
472  if( layer >= (int)ImagesMaxCount() )
473  layer = 0;
474  }
475 
476  return NO_AVAILABLE_LAYERS;
477 }
478 
479 
481 {
483 }
484 
485 
486 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
487 {
488  if( aRebuildLayerBox )
490 
491  m_SelLayerBox->SetSelection( GetActiveLayer() );
492 
493  int dcodeSelected = -1;
495 
496  if( gerber )
497  dcodeSelected = gerber->m_Selected_Tool;
498 
499  if( m_DCodeSelector )
500  {
502  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
503  m_DCodeSelector->Enable( gerber != NULL );
504  }
505 }
506 
507 
509 {
510  auto remapping = GetImagesList()->SortImagesByZOrder();
511 
513  syncLayerBox( true );
514 
515  std::unordered_map<int, int> view_remapping;
516 
517  for( auto it : remapping )
518  {
519  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
520  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
521  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
522  }
523 
524  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
525  GetCanvas()->Refresh();
526 }
527 
528 
530 {
531  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
532  aOptions.m_DisplayFlashedItemsFill );
533  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
534  aOptions.m_DisplayLinesFill );
535  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
536  aOptions.m_DisplayPolygonsFill );
537 
538  m_DisplayOptions = aOptions;
539 
541 
542  auto view = GetCanvas()->GetView();
543 
544  if( update_flashed )
545  {
547  {
548  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
549 
550  switch( item->m_Shape )
551  {
552  case GBR_SPOT_CIRCLE:
553  case GBR_SPOT_RECT:
554  case GBR_SPOT_OVAL:
555  case GBR_SPOT_POLY:
556  case GBR_SPOT_MACRO:
557  return true;
558 
559  default:
560  return false;
561  }
562  } );
563  }
564  else if( update_lines )
565  {
566  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
567  {
568  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
569 
570  switch( item->m_Shape )
571  {
572  case GBR_CIRCLE:
573  case GBR_ARC:
574  case GBR_SEGMENT:
575  return true;
576 
577  default:
578  return false;
579  }
580  } );
581  }
582  else if( update_polygons )
583  {
584  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
585  {
586  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
587 
588  return ( item->m_Shape == GBR_POLYGON );
589  } );
590  }
591 
592  view->UpdateAllItems( KIGFX::COLOR );
593  GetCanvas()->Refresh();
594 }
595 
596 
598 {
600 
601  // Display the gerber filename
602  if( gerber == NULL )
603  {
604  SetTitle( _("Gerber Viewer") );
605 
606  SetStatusText( wxEmptyString, 0 );
607 
608  wxString info;
609  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
610  m_TextInfo->SetValue( info );
611 
612  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
613  m_auimgr.Update();
614 
615  ClearMsgPanel();
616  return;
617  }
618  else
619  {
620  wxString title;
621  wxFileName filename( gerber->m_FileName );
622 
623  title.Printf( wxT( "%s%s \u2014 " ) + _( "Gerber Viewer" ),
624  filename.GetFullName(),
625  gerber->m_IsX2_file ? wxS( " " ) + _( "(with X2 attributes)" )
626  : wxString( wxEmptyString ) );
627  SetTitle( title );
628 
629  gerber->DisplayImageInfo( this );
630 
631  // Display Image Name and Layer Name (from the current gerber data):
632  wxString status;
633  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
634  gerber->m_ImageName,
635  gerber->GetLayerParams().m_LayerName );
636  SetStatusText( status, 0 );
637 
638  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
639  wxString info;
640  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
641  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
642  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
643  gerber->m_FmtScale.x,
644  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
645  gerber->m_FmtScale.y,
646  gerber->m_NoTrailingZeros ? 'T' : 'L' );
647 
648  if( gerber->m_IsX2_file )
649  info << wxT(" ") << _( "X2 attr" );
650 
651  m_TextInfo->SetValue( info );
652 
653  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
654  m_auimgr.Update();
655  }
656 }
657 
658 
659 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
660 {
661  switch( aLayerID )
662  {
665  case LAYER_GERBVIEW_GRID: return IsGridVisible();
667  case LAYER_GERBVIEW_BACKGROUND: return true;
668 
669  default:
670  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d", aLayerID ) );
671  }
672 
673  return true;
674 }
675 
676 
678 {
679  LSET visible = LSET::AllLayersMask();
680 
681  if( GetCanvas() )
682  {
683  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
684  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
685  }
686 
687  return visible;
688 }
689 
690 
692 {
693  if( GetCanvas() )
694  {
695  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
696  {
697  bool v = aLayerMask[i];
698  int layer = GERBER_DRAW_LAYER( i );
699  GetCanvas()->GetView()->SetLayerVisible( layer, v );
702  }
703  }
704 }
705 
706 
707 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
708 {
709  return m_LayersManager->IsLayerVisible( aLayer );
710 }
711 
712 
714 {
715  COLOR4D color = COLOR4D::UNSPECIFIED;
716  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
717 
718  switch( aLayerID )
719  {
721  case LAYER_DCODES:
724  color = settings->GetColor( aLayerID );
725  break;
726 
727  case LAYER_GERBVIEW_GRID:
728  color = GetGridColor();
729  break;
730 
731  default:
732  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d",
733  aLayerID ) );
734  }
735 
736  return color;
737 }
738 
739 
741 {
744 }
745 
746 
748 {
749  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
750 
751  switch( aLayerID )
752  {
754  case LAYER_DCODES:
755  settings->SetColor( aLayerID, aColor );
756  break;
757 
759  settings->SetColor( LAYER_GERBVIEW_DRAWINGSHEET, aColor );
760  // LAYER_DRAWINGSHEET color is also used to draw the drawing-sheet
761  // FIX ME: why LAYER_DRAWINGSHEET must be set, although LAYER_GERBVIEW_DRAWINGSHEET
762  // is used to initialize the drawing-sheet color layer.
763  settings->SetColor( LAYER_DRAWINGSHEET, aColor );
764  break;
765 
766  case LAYER_GERBVIEW_GRID:
767  SetGridColor( aColor );
768  settings->SetColor( aLayerID, aColor );
769  break;
770 
772  SetDrawBgColor( aColor );
773  settings->SetColor( aLayerID, aColor );
774  break;
775 
776  default:
777  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d",
778  aLayerID ) );
779  }
780 }
781 
782 
784 {
787  else
788  return GetDrawBgColor();
789 }
790 
791 
793 {
794  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
795 }
796 
797 
798 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
799 {
800  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
802 }
803 
804 
805 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
806 {
807  m_activeLayer = aLayer;
808 
809  if( doLayerWidgetUpdate )
810  m_LayersManager->SelectLayer( aLayer );
811 
813 
814  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
815  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
816 
818  GetCanvas()->Refresh();
819 }
820 
821 
822 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
823 {
824  m_paper = aPageSettings;
825 
826  if( GetScreen() )
827  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
828 
829  GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
830 
831  // Prepare drawing-sheet template
833  &Prj(), &GetTitleBlock() );
834 
835  if( GetScreen() )
836  {
837  drawingSheet->SetPageNumber( "1" );
838  drawingSheet->SetSheetCount( 1 );
839  }
840 
842 
843  // Draw panel takes ownership of the drawing-sheet
844  drawPanel->SetDrawingSheet( drawingSheet );
845 }
846 
847 
849 {
850  return m_paper;
851 }
852 
853 
854 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
855 {
856  // this function is only needed because EDA_DRAW_FRAME is not compiled
857  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
858  // into an application specific source file.
859  return GetPageSettings().GetSizeIU();
860 }
861 
862 
864 {
865  wxASSERT( m_gerberLayout );
866  return m_gerberLayout->GetTitleBlock();
867 }
868 
869 
870 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
871 {
872  wxASSERT( m_gerberLayout );
873  m_gerberLayout->SetTitleBlock( aTitleBlock );
874 }
875 
876 
878 {
879  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_GRID );
880 }
881 
882 
884 {
885  Pgm().GetSettingsManager().GetColorSettings()->SetColor( LAYER_GRID, aColor );
886  GetCanvas()->GetGAL()->SetGridColor( aColor );
887  m_gridColor = aColor;
888 }
889 
890 
891 /*
892  * Display the grid status.
893  */
895 {
896  wxString line;
897 
898  line.Printf( "grid X %s Y %s",
899  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
900  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
901 
902  SetStatusText( line, 4 );
903 }
904 
905 
907 {
909 
910  if( !GetScreen() )
911  return;
912 
913  wxString line;
915 
916  if( GetShowPolarCoords() ) // display relative polar coordinates
917  {
918  double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
919  double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
920  double theta = RAD2DEG( atan2( -dy, dx ) );
921  double ro = hypot( dx, dy );
922 
923  line.Printf( wxT( "r %s theta %s" ),
924  MessageTextFromValue( GetUserUnits(), ro, false ),
925  MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) );
926 
927  SetStatusText( line, 3 );
928  }
929 
930  // Display absolute coordinates:
931  line.Printf( wxT( "X %s Y %s" ),
932  MessageTextFromValue( GetUserUnits(), cursorPos.x, false ),
933  MessageTextFromValue( GetUserUnits(), cursorPos.y, false ) );
934  SetStatusText( line, 2 );
935 
936  if( !GetShowPolarCoords() )
937  {
938  // Display relative cartesian coordinates:
939  double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
940  double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
941 
942  line.Printf( wxT( "dx %s dy %s dist %s" ),
943  MessageTextFromValue( GetUserUnits(), dXpos, false ),
944  MessageTextFromValue( GetUserUnits(), dYpos, false ),
945  MessageTextFromValue( GetUserUnits(), hypot( dXpos, dYpos ), false ) );
946  SetStatusText( line, 3 );
947  }
948 
949  DisplayGridMsg();
950 }
951 
952 
954 {
955  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
956 }
957 
958 
960 {
962 }
963 
964 
966 {
967  // Called on units change (see EDA_DRAW_FRAME)
971 }
972 
973 
975 {
977 
978  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
979 
980  if( m_toolManager )
981  {
983  GetCanvas()->GetViewControls(), config(), this );
985  }
986 
988 
990 
991  galCanvas->GetView()->RecacheAllItems();
992  galCanvas->SetEventDispatcher( m_toolDispatcher );
993  galCanvas->StartDrawing();
994 
997 
999  ReCreateMenuBar();
1000 }
1001 
1002 
1004  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1005 {
1006  wxTreebook* book = aParent->GetTreebook();
1007 
1008  book->AddPage( new wxPanel( book ), _( "GerbView" ) );
1009  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
1010  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1011 
1012  aHotkeysPanel->AddHotKeys( GetToolManager() );
1013 }
1014 
1015 
1016 
1018 {
1019  // Create the manager and dispatcher & route draw panel events to the dispatcher
1022  GetCanvas()->GetViewControls(), config(), this );
1023  m_actions = new GERBVIEW_ACTIONS();
1025 
1026  // Register tools
1034 
1035  // Run the selection tool, it is supposed to be always active
1036  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1037 }
1038 
1039 
1041 {
1043 
1045  EDITOR_CONDITIONS cond( this );
1046 
1047  wxASSERT( mgr );
1048 
1049 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1050 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
1051 
1053  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
1057  CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
1058 
1062 
1064  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
1066  CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
1068  CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1069 
1070  auto flashedDisplayOutlinesCond =
1071  [this] ( const SELECTION& )
1072  {
1074  };
1075 
1076  auto linesFillCond =
1077  [this] ( const SELECTION& )
1078  {
1080  };
1081 
1082  auto polygonsFilledCond =
1083  [this] ( const SELECTION& )
1084  {
1086  };
1087 
1088  auto negativeObjectsCond =
1089  [this] ( const SELECTION& )
1090  {
1092  };
1093 
1094  auto dcodeCond =
1095  [this] ( const SELECTION& )
1096  {
1097  return IsElementVisible( LAYER_DCODES );
1098  };
1099 
1100  auto diffModeCond =
1101  [this] ( const SELECTION& )
1102  {
1104  };
1105 
1106  auto highContrastModeCond =
1107  [this] ( const SELECTION& )
1108  {
1110  };
1111 
1112  auto flipGerberCond =
1113  [this] ( const SELECTION& )
1114  {
1116  };
1117 
1118  auto layersManagerShownCondition =
1119  [this] ( const SELECTION& aSel )
1120  {
1122  };
1123 
1125  CHECK( flashedDisplayOutlinesCond ) );
1127  mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1128  mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1129  mgr->SetConditions( GERBVIEW_ACTIONS::dcodeDisplay, CHECK( dcodeCond ) );
1130  mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
1131  mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1132  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1134  CHECK( layersManagerShownCondition ) );
1135 
1136 #undef CHECK
1137 #undef ENABLE
1138 }
1139 
1140 
1141 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1142 {
1143  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1144 
1145  RecreateToolbars();
1146  Layout();
1147  SendSizeEvent();
1148 }
1149 
1150 
1152 {
1153  return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1154 }
1155 
1156 
1158 {
1160 
1161  // show/hide auxiliary Vertical layers and visibility manager toolbar
1162  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1163  m_auimgr.Update();
1164 }
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:90
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
Save 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)
Take care of display settings for the given layer to be displayed in high contrast mode.
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:1425
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 SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for worksheet 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:102
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
int color
Definition: DXF_plotter.cpp:60
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:1380
double RAD2DEG(double rad)
Definition: trigo.h:232
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.
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
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)
Function SetDCodeSelection.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
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:81
Color has changed.
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
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:279
std::vector< double > zoom_factors
Definition: app_settings.h:86
void DeactivateTool()
Deactivate the currently active tool.
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.
FILE_HISTORY m_zipFileHistory
wxTreebook * GetTreebook()
Definition: paged_dialog.h:52
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:47
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:52
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:157
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:57
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.
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 ...
#define NULL
#define GERBER_DRAWLAYERS_COUNT
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:574
bool IsGridVisible() const
#define NO_AVAILABLE_LAYERS
void Clear()
Remove all items from the view.
Definition: view.cpp:1091
static TOOL_ACTION toggleGrid
Definition: actions.h:143
GRID_SETTINGS grid
Definition: app_settings.h:89
bool LoadGerberFiles(const wxString &aFileName)
Load a photoplot (Gerber) file or many files.
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:147
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
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:152
ACTIONS * m_actions
Definition: tools_holder.h:158
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:68
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.
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:387
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
Definition: view.cpp:682
GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied in...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define ZOOM_LIST_GERBVIEW
Definition: zoom_defines.h:29
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.
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:104
Handle actions that are shared between different applications.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=NULL)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: ui_common.cpp:73
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.
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:148
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:159
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)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id.
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:157
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
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.
#define _(s)
Definition: 3d_actions.cpp:33
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
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:137
void SetLayerColor(int aLayer, COLOR4D aColor)
wxStaticText * m_dcodeText
bool m_FlipGerberView
Display as a mirror image.
virtual void SetGridColor(COLOR4D aColor) override
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:197
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)
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...
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:55
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
drawingsheet frame and titleblock
void UpdateStatusBar() override
Update the status bar information.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
#define GERBER_DRAW_LAYER(x)
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
void 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
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)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
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:106
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
Rendering engine changes.
Definition: tool_base.h:82
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes 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.
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:156
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:94
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.
void SetColor(int aLayer, COLOR4D aColor)
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:69
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)