KiCad PCB EDA Suite
gerbview_frame.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <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 
65 
66 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
67  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
69  m_activeLayer( 0 ),
71  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
73  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
75  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
76  m_TextInfo( nullptr )
77 {
78  m_maximizeByDefault = true;
79  m_gerberLayout = nullptr;
81  m_showBorderAndTitleBlock = false; // true for reference drawings.
82  m_SelLayerBox = nullptr;
83  m_DCodeSelector = nullptr;
84  m_SelComponentBox = nullptr;
85  m_SelNetnameBox = nullptr;
86  m_SelAperAttributesBox = nullptr;
87  m_cmpText = nullptr;
88  m_netText = nullptr;
89  m_apertText = nullptr;
90  m_dcodeText = nullptr;
91  m_displayMode = 0;
92  m_aboutTitle = "GerbView";
93 
94  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
95  // some methods in code and avoid link errors
96 
97  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
98  m_drillFileHistory.SetMaxFiles( fileHistorySize );
99  m_zipFileHistory.SetMaxFiles( fileHistorySize );
100  m_jobFileHistory.SetMaxFiles( fileHistorySize );
101 
102  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
105 
106  SetCanvas( galCanvas );
107 
108  // GerbView requires draw priority for rendering negative objects
109  galCanvas->GetView()->UseDrawPriority( true );
110 
111  // Give an icon
112  wxIcon icon;
113  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
114  SetIcon( icon );
115 
116  // Be sure a page info is set. this default value will be overwritten later.
117  PAGE_INFO pageInfo( wxT( "GERBER" ) );
118  SetLayout( new GBR_LAYOUT() );
119  SetPageSettings( pageInfo );
120 
121  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
122 
123  SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) );
124 
125  // Create the PCB_LAYER_WIDGET *after* SetLayout():
127 
128  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
129  // initialize parameters in m_LayersManager
130  LoadSettings( config() );
131 
132  setupTools();
134  ReCreateMenuBar();
138 
139  m_auimgr.SetManagedWindow( this );
140 
141  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
142  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
143  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
144 
145  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
146  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
147  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
148  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
149 
150  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
151 
152  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,
153  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
154  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
155  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
156 
157  ReFillLayerWidget(); // this is near end because contents establish size
158  m_auimgr.Update();
159 
160  SetActiveLayer( 0, true );
162 
164 
166 
167  setupUnits( config() );
168 
169  // Enable the axes to match legacy draw style
170  auto& galOptions = GetGalDisplayOptions();
171  galOptions.m_axesEnabled = true;
172  galOptions.NotifyChanged();
173 
175  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
176 
178 
179  // Ensure the window is on top
180  Raise();
181 }
182 
183 
185 {
186  // Shutdown all running tools
187  if( m_toolManager )
189 
190  GetCanvas()->GetView()->Clear();
191 
193  delete m_gerberLayout;
194 }
195 
196 
198 {
199  // No more vetos
200  m_isClosing = true;
201  GetCanvas()->StopDrawing();
202  GetCanvas()->GetView()->Clear();
203 
204  if( m_toolManager )
206 
207  // Be sure any OpenGL event cannot be fired after frame deletion:
208  GetCanvas()->SetEvtHandlerEnabled( false );
209 
210  Destroy();
211 }
212 
213 
214 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
215 {
216  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
217  // when trying to change the view if it is not fully initialized.
218  // It happens when starting Gerbview with a gerber job file to load
219  if( !IsShown() )
220  Show();
221 
222  // The current project path is also a valid command parameter. Check if a single path
223  // rather than a file name was passed to GerbView and use it as the initial MRU path.
224  if( aFileSet.size() > 0 )
225  {
226  wxString path = aFileSet[0];
227 
228  // For some reason wxApp appears to leave the trailing double quote on quoted
229  // parameters which are required for paths with spaces. Maybe this should be
230  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
231  // We can't buy a break!
232  if( path.Last() == wxChar( '\"' ) )
233  path.RemoveLast();
234 
235  if( !wxFileExists( path ) && wxDirExists( path ) )
236  {
237  m_mruPath = path;
238  return true;
239  }
240 
241  const unsigned limit = std::min( unsigned( aFileSet.size() ),
242  unsigned( GERBER_DRAWLAYERS_COUNT ) );
243 
244  int layer = 0;
245 
246  for( unsigned i = 0; i < limit; ++i, ++layer )
247  {
248  SetActiveLayer( layer );
249 
250  // Try to guess the type of file by its ext
251  // if it is .drl (Kicad files), .nc or .xnc it is a drill file
252  wxFileName fn( aFileSet[i] );
253  wxString ext = fn.GetExt();
254 
255  if( ext == DrillFileExtension || // our Excellon format
256  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
257  LoadExcellonFiles( aFileSet[i] );
258  else if( ext == GerberJobFileExtension )
259  LoadGerberJobFile( aFileSet[i] );
260  else
261  LoadGerberFiles( aFileSet[i] );
262  }
263  }
264 
265  Zoom_Automatique( true ); // Zoom fit in frame
266 
267  return true;
268 }
269 
270 
272 {
274 
275  if( aCfg->m_Window.grid.sizes.empty() )
276  {
277  aCfg->m_Window.grid.sizes = { "100 mil",
278  "50 mil",
279  "25 mil",
280  "20 mil",
281  "10 mil",
282  "5 mil",
283  "2.5 mil",
284  "2 mil",
285  "1 mil",
286  "0.5 mil",
287  "0.2 mil",
288  "0.1 mil",
289  "5.0 mm",
290  "2.5 mm",
291  "1.0 mm",
292  "0.5 mm",
293  "0.25 mm",
294  "0.2 mm",
295  "0.1 mm",
296  "0.05 mm",
297  "0.025 mm",
298  "0.01 mm" };
299  }
300 
301  if( aCfg->m_Window.zoom_factors.empty() )
302  {
303  aCfg->m_Window.zoom_factors = { 0.022,
304  0.035,
305  0.05,
306  0.08,
307  0.13,
308  0.22,
309  0.35,
310  0.6,
311  1.0,
312  2.2,
313  3.5,
314  5.0,
315  8.0,
316  13.0,
317  22.0,
318  35.0,
319  50.0,
320  80.0,
321  130.0,
322  220.0 };
323  }
324 
325  for( double& factor : aCfg->m_Window.zoom_factors )
326  factor = std::min( factor, MAX_ZOOM_FACTOR );
327 
328  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
329  wxCHECK( cfg, /*void*/ );
330 
332 
333  PAGE_INFO pageInfo( wxT( "GERBER" ) );
334  pageInfo.SetType( cfg->m_Appearance.page_type );
335  SetPageSettings( pageInfo );
336 
339 
343 }
344 
345 
347 {
349 
350  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
351  wxCHECK( cfg, /*void*/ );
352 
357 
361 
362  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
363  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
364 }
365 
366 
368 {
369  wxWindowUpdateLocker no_update( m_LayersManager );
370 
374 
375  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
376  wxSize bestz = m_LayersManager->GetBestSize();
377  bestz.x += 5; // gives a little margin
378 
379  lyrs.MinSize( bestz );
380  lyrs.BestSize( bestz );
381  lyrs.FloatingSize( bestz );
382 
383  if( lyrs.IsDocked() )
384  m_auimgr.Update();
385  else
386  m_LayersManager->SetSize( bestz );
387 
388  syncLayerWidget();
389 }
390 
391 
392 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
393 {
394  bool dcodes_changed = false;
395 
396  switch( aLayerID )
397  {
398  case LAYER_DCODES:
399  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
400  m_DisplayOptions.m_DisplayDCodes = aNewState;
401  break;
402 
404  {
406 
407  auto view = GetCanvas()->GetView();
408 
410  {
411  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
412 
413  // GetLayerPolarity() returns true for negative items
414  return ( item && item->GetLayerPolarity() );
415  } );
416  break;
417  }
418 
420  m_showBorderAndTitleBlock = aNewState;
421  // NOTE: LAYER_WORKSHEET always used for visibility, but the layer manager passes
422  // LAYER_GERBVIEW_WORKSHEET because of independent color control
423  GetCanvas()->GetView()->SetLayerVisible( LAYER_WORKSHEET, aNewState );
424  break;
425 
426  case LAYER_GERBVIEW_GRID:
427  SetGridVisibility( aNewState );
428  break;
429 
430  default:
431  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d",
432  aLayerID ) );
433  }
434 
435  if( dcodes_changed )
436  {
437  auto view = GetCanvas()->GetView();
438 
439  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
440  {
441  int layer = GERBER_DRAW_LAYER( i );
442  int dcode_layer = GERBER_DCODE_LAYER( layer );
443  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
444  }
445  }
446 
448  m_LayersManager->SetRenderState( aLayerID, aNewState );
449 }
450 
451 
453 {
454  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
455  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
458 
460 }
461 
462 
464 {
465  int layer = aLayer;
466 
467  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
468  {
469  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
470 
471  if( gerber == NULL ) // this graphic layer is available: use it
472  return layer;
473 
474  ++layer; // try next graphic layer
475 
476  if( layer >= (int)ImagesMaxCount() )
477  layer = 0;
478  }
479 
480  return NO_AVAILABLE_LAYERS;
481 }
482 
483 
485 {
487 }
488 
489 
490 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
491 {
492  if( aRebuildLayerBox )
494 
495  m_SelLayerBox->SetSelection( GetActiveLayer() );
496 
497  int dcodeSelected = -1;
499 
500  if( gerber )
501  dcodeSelected = gerber->m_Selected_Tool;
502 
503  if( m_DCodeSelector )
504  {
506  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
507  m_DCodeSelector->Enable( gerber != NULL );
508  }
509 }
510 
511 
513 {
514  auto remapping = GetImagesList()->SortImagesByZOrder();
515 
517  syncLayerBox( true );
518 
519  std::unordered_map<int, int> view_remapping;
520 
521  for( auto it : remapping )
522  {
523  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
524  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
525  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
526  }
527 
528  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
529  GetCanvas()->Refresh();
530 }
531 
532 
534 {
535  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
536  aOptions.m_DisplayFlashedItemsFill );
537  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
538  aOptions.m_DisplayLinesFill );
539  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
540  aOptions.m_DisplayPolygonsFill );
541 
542  m_DisplayOptions = aOptions;
543 
545 
546  auto view = GetCanvas()->GetView();
547 
548  if( update_flashed )
549  {
551  {
552  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
553 
554  switch( item->m_Shape )
555  {
556  case GBR_SPOT_CIRCLE:
557  case GBR_SPOT_RECT:
558  case GBR_SPOT_OVAL:
559  case GBR_SPOT_POLY:
560  case GBR_SPOT_MACRO:
561  return true;
562 
563  default:
564  return false;
565  }
566  } );
567  }
568  else if( update_lines )
569  {
570  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
571  {
572  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
573 
574  switch( item->m_Shape )
575  {
576  case GBR_CIRCLE:
577  case GBR_ARC:
578  case GBR_SEGMENT:
579  return true;
580 
581  default:
582  return false;
583  }
584  } );
585  }
586  else if( update_polygons )
587  {
588  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
589  {
590  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
591 
592  return ( item->m_Shape == GBR_POLYGON );
593  } );
594  }
595 
596  view->UpdateAllItems( KIGFX::COLOR );
597  GetCanvas()->Refresh();
598 }
599 
600 
602 {
604 
605  // Display the gerber filename
606  if( gerber == NULL )
607  {
608  SetTitle( "GerbView" );
609 
610  SetStatusText( wxEmptyString, 0 );
611 
612  wxString info;
613  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
614  m_TextInfo->SetValue( info );
615 
616  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
617  m_auimgr.Update();
618 
619  ClearMsgPanel();
620  return;
621  }
622  else
623  {
624  wxString title;
625  wxFileName filename( gerber->m_FileName );
626 
627  title.Printf( wxT( "%s%s \u2014 " ) + _( "GerbView" ),
628  filename.GetFullName(),
629  gerber->m_IsX2_file ? wxS( " " ) + _( "(with X2 attributes)" )
630  : wxString( wxEmptyString ) );
631  SetTitle( title );
632 
633  gerber->DisplayImageInfo( this );
634 
635  // Display Image Name and Layer Name (from the current gerber data):
636  wxString status;
637  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
638  gerber->m_ImageName,
639  gerber->GetLayerParams().m_LayerName );
640  SetStatusText( status, 0 );
641 
642  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
643  wxString info;
644  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
645  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
646  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
647  gerber->m_FmtScale.x,
648  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
649  gerber->m_FmtScale.y,
650  gerber->m_NoTrailingZeros ? 'T' : 'L' );
651 
652  if( gerber->m_IsX2_file )
653  info << wxT(" ") << _( "X2 attr" );
654 
655  m_TextInfo->SetValue( info );
656 
657  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
658  m_auimgr.Update();
659  }
660 }
661 
662 
663 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
664 {
665  switch( aLayerID )
666  {
669  case LAYER_GERBVIEW_GRID: return IsGridVisible();
671  case LAYER_GERBVIEW_BACKGROUND: return true;
672 
673  default:
674  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d", aLayerID ) );
675  }
676 
677  return true;
678 }
679 
680 
682 {
683  LSET visible = LSET::AllLayersMask();
684 
685  if( GetCanvas() )
686  {
687  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
688  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
689  }
690 
691  return visible;
692 }
693 
694 
696 {
697  if( GetCanvas() )
698  {
699  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
700  {
701  bool v = aLayerMask[i];
702  int layer = GERBER_DRAW_LAYER( i );
703  GetCanvas()->GetView()->SetLayerVisible( layer, v );
706  }
707  }
708 }
709 
710 
711 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
712 {
713  return m_LayersManager->IsLayerVisible( aLayer );
714 }
715 
716 
718 {
719  COLOR4D color = COLOR4D::UNSPECIFIED;
720  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
721 
722  switch( aLayerID )
723  {
725  case LAYER_DCODES:
728  color = settings->GetColor( aLayerID );
729  break;
730 
731  case LAYER_GERBVIEW_GRID:
732  color = GetGridColor();
733  break;
734 
735  default:
736  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d",
737  aLayerID ) );
738  }
739 
740  return color;
741 }
742 
743 
745 {
748 }
749 
750 
752 {
753  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
754 
755  switch( aLayerID )
756  {
758  case LAYER_DCODES:
759  settings->SetColor( aLayerID, aColor );
760  break;
761 
763  settings->SetColor( LAYER_GERBVIEW_WORKSHEET, aColor );
764  // LAYER_WORKSHEET color is alsu used to draw the worksheet
765  // FIX ME: why LAYER_WORKSHEET must be set, although LAYER_GERBVIEW_WORKSHEET
766  // is used to initialize the worksheet color layer.
767  settings->SetColor( LAYER_WORKSHEET, aColor );
768  break;
769 
770  case LAYER_GERBVIEW_GRID:
771  SetGridColor( aColor );
772  settings->SetColor( aLayerID, aColor );
773  break;
774 
776  SetDrawBgColor( aColor );
777  settings->SetColor( aLayerID, aColor );
778  break;
779 
780  default:
781  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d",
782  aLayerID ) );
783  }
784 }
785 
786 
788 {
791  else
792  return GetDrawBgColor();
793 }
794 
795 
797 {
798  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
799 }
800 
801 
802 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
803 {
804  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
806 }
807 
808 
809 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
810 {
811  m_activeLayer = aLayer;
812 
813  if( doLayerWidgetUpdate )
814  m_LayersManager->SelectLayer( aLayer );
815 
817 
818  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
819  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
820 
822  GetCanvas()->Refresh();
823 }
824 
825 
826 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
827 {
828  m_paper = aPageSettings;
829 
830  if( GetScreen() )
831  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
832 
833  auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
834 
835  // Prepare worksheet template
836  auto worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(),
837  &Prj(), &GetTitleBlock() );
838 
839  if( GetScreen() )
840  {
841  worksheet->SetPageNumber( "1" );
842  worksheet->SetSheetCount( 1 );
843  }
844 
845  worksheet->SetColorLayer( LAYER_GERBVIEW_WORKSHEET );
846 
847  // Draw panel takes ownership of the worksheet
848  drawPanel->SetWorksheet( worksheet );
849 }
850 
851 
853 {
854  return m_paper;
855 }
856 
857 
858 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
859 {
860  // this function is only needed because EDA_DRAW_FRAME is not compiled
861  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
862  // into an application specific source file.
863  return GetPageSettings().GetSizeIU();
864 }
865 
866 
868 {
869  wxASSERT( m_gerberLayout );
870  return m_gerberLayout->GetTitleBlock();
871 }
872 
873 
874 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
875 {
876  wxASSERT( m_gerberLayout );
877  m_gerberLayout->SetTitleBlock( aTitleBlock );
878 }
879 
880 
882 {
883  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_GRID );
884 }
885 
886 
888 {
889  Pgm().GetSettingsManager().GetColorSettings()->SetColor( LAYER_GRID, aColor );
890  GetCanvas()->GetGAL()->SetGridColor( aColor );
891  m_gridColor = aColor;
892 }
893 
894 
895 /*
896  * Display the grid status.
897  */
899 {
900  wxString line;
901 
902  line.Printf( "grid X %s Y %s",
903  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
904  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
905 
906  SetStatusText( line, 4 );
907 }
908 
909 
911 {
913 
914  if( !GetScreen() )
915  return;
916 
917  wxString line;
919 
920  if( GetShowPolarCoords() ) // display relative polar coordinates
921  {
922  double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
923  double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
924  double theta = RAD2DEG( atan2( -dy, dx ) );
925  double ro = hypot( dx, dy );
926 
927  line.Printf( wxT( "r %s theta %s" ),
928  MessageTextFromValue( GetUserUnits(), ro, false ),
929  MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) );
930 
931  SetStatusText( line, 3 );
932  }
933 
934  // Display absolute coordinates:
935  line.Printf( wxT( "X %s Y %s" ),
936  MessageTextFromValue( GetUserUnits(), cursorPos.x, false ),
937  MessageTextFromValue( GetUserUnits(), cursorPos.y, false ) );
938  SetStatusText( line, 2 );
939 
940  if( !GetShowPolarCoords() )
941  {
942  // Display relative cartesian coordinates:
943  double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
944  double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
945 
946  line.Printf( wxT( "dx %s dy %s dist %s" ),
947  MessageTextFromValue( GetUserUnits(), dXpos, false ),
948  MessageTextFromValue( GetUserUnits(), dYpos, false ),
949  MessageTextFromValue( GetUserUnits(), hypot( dXpos, dYpos ), false ) );
950  SetStatusText( line, 3 );
951  }
952 
953  DisplayGridMsg();
954 }
955 
956 
958 {
959  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
960 }
961 
962 
964 {
966 }
967 
968 
970 {
971  // Called on units change (see EDA_DRAW_FRAME)
975 }
976 
977 
979 {
981 
982  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
983 
984  if( m_toolManager )
985  {
987  GetCanvas()->GetViewControls(), config(), this );
989  }
990 
992 
994 
995  galCanvas->GetView()->RecacheAllItems();
996  galCanvas->SetEventDispatcher( m_toolDispatcher );
997  galCanvas->StartDrawing();
998 
1001 
1003  ReCreateMenuBar();
1004 }
1005 
1006 
1008  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1009 {
1010  wxTreebook* book = aParent->GetTreebook();
1011 
1012  book->AddPage( new wxPanel( book ), _( "Gerbview" ) );
1013  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
1014  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1015 
1016  aHotkeysPanel->AddHotKeys( GetToolManager() );
1017 }
1018 
1019 
1020 
1022 {
1023  // Create the manager and dispatcher & route draw panel events to the dispatcher
1026  GetCanvas()->GetViewControls(), config(), this );
1027  m_actions = new GERBVIEW_ACTIONS();
1029 
1030  // Register tools
1038 
1039  // Run the selection tool, it is supposed to be always active
1040  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1041 }
1042 
1043 
1045 {
1047 
1049  EDITOR_CONDITIONS cond( this );
1050 
1051  wxASSERT( mgr );
1052 
1053 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1054 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
1055 
1059 
1063 
1067 
1070 
1071 
1072  auto flashedDisplayOutlinesCond =
1073  [this] ( const SELECTION& )
1074  {
1076  };
1077 
1078  auto linesFillCond =
1079  [this] ( const SELECTION& )
1080  {
1082  };
1083 
1084  auto polygonsFilledCond =
1085  [this] ( const SELECTION& )
1086  {
1088  };
1089 
1090  auto negativeObjectsCond =
1091  [this] ( const SELECTION& )
1092  {
1094  };
1095 
1096  auto dcodeCond =
1097  [this] ( const SELECTION& )
1098  {
1099  return IsElementVisible( LAYER_DCODES );
1100  };
1101 
1102  auto diffModeCond =
1103  [this] ( const SELECTION& )
1104  {
1106  };
1107 
1108  auto highContrastModeCond =
1109  [this] ( const SELECTION& )
1110  {
1112  };
1113 
1114  auto flipGerberCond =
1115  [this] ( const SELECTION& )
1116  {
1118  };
1119 
1120  auto layersManagerShownCondition =
1121  [this] ( const SELECTION& aSel )
1122  {
1124  };
1125 
1126  mgr->SetConditions( GERBVIEW_ACTIONS::flashedDisplayOutlines, CHECK( flashedDisplayOutlinesCond ) );
1128  mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1129  mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1130  mgr->SetConditions( GERBVIEW_ACTIONS::dcodeDisplay, CHECK( dcodeCond ) );
1131  mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
1132  mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1133  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1134  mgr->SetConditions( GERBVIEW_ACTIONS::toggleLayerManager, 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...
GBR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
Definition: gbr_layout.h:46
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Definition: base_units.cpp:123
wxString m_LayerName
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
static TOOL_ACTION layerChanged
void SetVisibleElementColor(int aLayerID, COLOR4D aColor)
void SortLayersByX2Attributes()
virtual void SetHighContrastLayer(int aLayer)
Function SetHighContrastLayer Takes care of display settings for the given layer to be displayed in h...
std::vector< wxString > m_JobFileHistory
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
wxString m_mruPath
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Updates items in the view according to the given flags and condition.
Definition: view.cpp:1431
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
SETTINGS_MANAGER * GetSettingsManager() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void UpdateStatusBar() override
Update the status bar information.
void DeleteAllImages()
remove all loaded data in list, and delete all images.
ACTION_TOOLBAR * m_auxiliaryToolBar
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
Function GetNegativeItemsColor.
SELECTION_CONDITION FullscreenCursor()
Creates a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
virtual void SetScreen(BASE_SCREEN *aScreen)
COLOR4D GetVisibleElementColor(int aLayerID)
Function GetVisibleElementColor returns the color of a gerber visible element.
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
static TOOL_ACTION zoomTool
Definition: actions.h:97
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
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()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1377
double RAD2DEG(double rad)
Definition: trigo.h:218
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
Definition: filehistory.cpp:67
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Creates a functor testing if the specified tool is the current active tool in the frame.
#define MAX_ZOOM_FACTOR
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters (TODO:...
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function SetActiveLayer will change the currently active layer to aLayer and update the GERBER_LAYER_...
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:119
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
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)
Function RunAction() Runs 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 TOOL_ACTION standardGraphics
Definition: actions.h:164
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Creates a functor testing if the specified canvas is active in the frame.
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
Definition: filehistory.cpp:45
void AddHotKeys(TOOL_MANAGER *aToolMgr)
static TOOL_ACTION toggleLayerManager
const wxString & GetType() const
Definition: page_info.h:98
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
ACTION_MANAGER.
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
Visibility flag has changed.
Definition: view_item.h:58
The base class for create windows for drawing purpose.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
COLOR4D m_gridColor
Class that groups generic conditions for editor states.
std::vector< double > zoom_factors
Definition: app_settings.h:86
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
static TOOL_ACTION dcodeDisplay
static TOOL_ACTION negativeObjectDisplay
wxChoice * m_SelNetnameBox
void ActivateGalCanvas() override
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
void SetGridVisibility(bool aVisible) override
Function SetGridVisibility(), virtual from EDA_DRAW_FRAME It may be overloaded by derived classes.
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
GERBVIEW_ACTIONS.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
static TOOL_ACTION toggleDiffMode
void ReCreateHToolbar() override
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
FILE_HISTORY m_zipFileHistory
wxTreebook * GetTreebook()
Definition: paged_dialog.h:50
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
#define GERBER_DCODE_LAYER(x)
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:48
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
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:152
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
static TOOL_ACTION flipGerberView
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
bool m_DiffMode
Display layers in diff mode.
Item is being added to the view.
Definition: view_item.h:62
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Updates the display options and refreshes the view as needed.
LSET is a set of PCB_LAYER_IDs.
std::vector< wxString > sizes
Definition: app_settings.h:52
unsigned ImagesMaxCount() const
The max number of file images.
COLOR4D GetGridColor() override
std::vector< wxString > m_DrillFileHistory
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
PAGE_INFO m_paper
SELECTION_CONDITION GridVisible()
Creates a functor testing if the grid is visible in a frame.
void ReCreateAuxiliaryToolbar() override
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
#define NULL
#define GERBER_DRAWLAYERS_COUNT
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:571
bool IsGridVisible() const
#define NO_AVAILABLE_LAYERS
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1089
static TOOL_ACTION toggleGrid
Definition: actions.h:138
GRID_SETTINGS grid
Definition: app_settings.h:89
bool LoadGerberFiles(const wxString &aFileName)
function LoadGerberFiles Load a photoplot (Gerber) file or many files.
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allows Gerbview to install its preferences panels into the preferences dialog.
SHAPE_POLY_SET.
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
bool m_showBorderAndTitleBlock
static TOOL_ACTION inchesUnits
Definition: actions.h:142
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
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:147
ACTIONS * m_actions
Definition: tools_holder.h:49
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:69
Definition of file extensions used in Kicad.
Base window classes and related definitions.
bool IsElementVisible(int aLayerID) const
Function IsElementVisible tests whether a given element category is visible.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
GBR_LAYOUT * m_gerberLayout
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:787
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:385
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:687
GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied in...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void doCloseWindow() override
FILE_HISTORY m_drillFileHistory
GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
COMMON_CONTROL.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
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:72
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
#define GERBVIEW_FRAME_NAME
GERBVIEW_FRAME is the main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
const BITMAP_OPAQUE icon_gerbview_xpm[1]
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
SELECTION_CONDITION PolarCoordinates()
Creates a functor testing if polar coordinates are current being used.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static TOOL_ACTION milsUnits
Definition: actions.h:143
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:50
COMMON_TOOLS.
Definition: common_tools.h:38
static TOOL_ACTION flashedDisplayOutlines
GBR_LAYOUT * GetGerberLayout() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs 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
Function DisplayGridMsg()
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id.
COLOR4D GetColor(int aLayer) const
WINDOW_SETTINGS m_Window
Definition: app_settings.h:173
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:85
wxStaticText * m_cmpText
int GetActiveLayer() const
Function SetActiveLayer returns the active layer.
GERBVIEW_SELECTION_TOOL.
wxChoice * m_SelAperAttributesBox
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
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.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:200
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
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
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:163
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:41
EDA_UNITS m_userUnits
#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 COLOR_SETTINGS * GetColorSettings()
Returns a pointer to the active color theme settings.
virtual void SetGridColor(COLOR4D aColor) override
void syncLayerWidget()
Function syncLayerWidget updates the currently "selected" layer within the GERBER_LAYER_WIDGET.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxChoice * m_SelComponentBox
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
#define CHECK(x)
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual COLOR4D GetDrawBgColor() const
wxStaticText * m_netText
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:76
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
void UpdateStatusBar() override
Update the status bar information.
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
#define GERBER_DRAW_LAYER(x)
void InitTools()
Function InitTools() Initializes all registered tools.
void ReFillRender()
Function ReFillRender Rebuild Render for instance after the config is read.
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Recreates the menu bar.
wxStaticText * m_apertText
int getNextAvailableLayer(int aLayer=0) const
Function getNextAvailableLayer finds the next empty layer starting at aLayer and returns it to the ca...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
BASE_SCREEN class implementation.
Message panel definition file.
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
void SetLayout(GBR_LAYOUT *aLayout)
Function SetLayout sets the m_gerberLayout member in such as way as to ensure deleting any previous G...
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible tests whether a given layer is visible.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
static TOOL_ACTION highContrastMode
Definition: actions.h:101
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
Rendering engine changes.
Definition: tool_base.h:83
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes the row selection in the layer list to aLayer provided.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetElementVisibility(int aLayerID, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
virtual void SetGridVisibility(bool aVisible)
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers; called upon loading new gerber fil...
void UpdateTitleAndInfo()
Function UpdateTitleAndInfo displays the short filename (if exists) of the selected layer on the capt...
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:151
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:89
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
const std::string DrillFileExtension
PCBNEW_CONTROL.
void SetColor(int aLayer, COLOR4D aColor)
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:402
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:70
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)