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 #include <wx/treebook.h>
61 
65 #include <zoom_defines.h>
66 
67 
68 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
69  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
71  m_TextInfo( nullptr ),
73  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
75  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
77  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
78  m_activeLayer( 0 )
79 {
80  m_maximizeByDefault = true;
81  m_gerberLayout = nullptr;
83  m_showBorderAndTitleBlock = false; // true for reference drawings.
84  m_SelLayerBox = nullptr;
85  m_DCodeSelector = nullptr;
86  m_SelComponentBox = nullptr;
87  m_SelNetnameBox = nullptr;
88  m_SelAperAttributesBox = nullptr;
89  m_cmpText = nullptr;
90  m_netText = nullptr;
91  m_apertText = nullptr;
92  m_dcodeText = nullptr;
93  m_displayMode = 0;
94  m_aboutTitle = _( "KiCad Gerber Viewer" );
95 
96  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
97  // some methods in code and avoid link errors
98 
99  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
100  m_drillFileHistory.SetMaxFiles( fileHistorySize );
101  m_zipFileHistory.SetMaxFiles( fileHistorySize );
102  m_jobFileHistory.SetMaxFiles( fileHistorySize );
103 
104  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
107 
108  SetCanvas( galCanvas );
109 
110  // GerbView requires draw priority for rendering negative objects
111  galCanvas->GetView()->UseDrawPriority( true );
112 
113  // Give an icon
114  wxIcon icon;
115  wxIconBundle icon_bundle;
116 
117  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview ) );
118  icon_bundle.AddIcon( icon );
119  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_32 ) );
120  icon_bundle.AddIcon( icon );
121  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_16 ) );
122  icon_bundle.AddIcon( icon );
123 
124  SetIcons( icon_bundle );
125 
126  // Be sure a page info is set. this default value will be overwritten later.
127  PAGE_INFO pageInfo( wxT( "GERBER" ) );
128  SetLayout( new GBR_LAYOUT() );
129  SetPageSettings( pageInfo );
130 
131  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
132 
133  SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) );
134 
135  // Create the PCB_LAYER_WIDGET *after* SetLayout():
137 
138  // Update the minimum string length in the layer panel with the length of the last default layer
139  wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(),
140  false, true );
142 
143  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
144  // initialize parameters in m_LayersManager
145  LoadSettings( config() );
146 
147  setupTools();
149  ReCreateMenuBar();
153 
154  m_auimgr.SetManagedWindow( this );
155 
156  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
157  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top()
158  .Layer(4) );
159  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom()
160  .Layer( 6 ) );
161  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left()
162  .Layer( 3 ) );
163  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right()
164  .Layer( 3 ).Caption( _( "Layers Manager" ) ).PaneBorder( false )
165  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
166 
167  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
168 
169  ReFillLayerWidget(); // this is near end because contents establish size
170  m_auimgr.Update();
171 
172  SetActiveLayer( 0, true );
174 
176 
178 
179  setupUnits( config() );
180 
181  // Enable the axes to match legacy draw style
182  auto& galOptions = GetGalDisplayOptions();
183  galOptions.m_axesEnabled = true;
184  galOptions.NotifyChanged();
185 
187  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
188 
190 
191  // Ensure the window is on top
192  Raise();
193 
194  // Register a call to update the toolbar sizes. It can't be done immediately because
195  // it seems to require some sizes calculated that aren't yet (at least on GTK).
196  CallAfter( [&]()
197  {
198  // Ensure the controls on the toolbars all are correctly sized
200  } );
201 }
202 
203 
205 {
206  // Ensure m_canvasType is up to date, to save it in config
208 
209  // Shutdown all running tools
210  if( m_toolManager )
212 
213  GetCanvas()->GetView()->Clear();
214 
216  delete m_gerberLayout;
217 }
218 
219 
221 {
222  // No more vetos
223  m_isClosing = true;
224  GetCanvas()->StopDrawing();
225  GetCanvas()->GetView()->Clear();
226 
227  if( m_toolManager )
229 
230  // Be sure any OpenGL event cannot be fired after frame deletion:
231  GetCanvas()->SetEvtHandlerEnabled( false );
232 
233  Destroy();
234 }
235 
236 
237 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
238 {
239  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
240  // when trying to change the view if it is not fully initialized.
241  // It happens when starting GerbView with a gerber job file to load
242  if( !IsShown() )
243  Show();
244 
245  // The current project path is also a valid command parameter. Check if a single path
246  // rather than a file name was passed to GerbView and use it as the initial MRU path.
247  if( aFileSet.size() > 0 )
248  {
249  wxString path = aFileSet[0];
250 
251  // For some reason wxApp appears to leave the trailing double quote on quoted
252  // parameters which are required for paths with spaces. Maybe this should be
253  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
254  // We can't buy a break!
255  if( path.Last() == wxChar( '\"' ) )
256  path.RemoveLast();
257 
258  if( !wxFileExists( path ) && wxDirExists( path ) )
259  {
260  m_mruPath = path;
261  return true;
262  }
263 
264  const unsigned limit = std::min( unsigned( aFileSet.size() ),
265  unsigned( GERBER_DRAWLAYERS_COUNT ) );
266 
267  int layer = 0;
268 
269  for( unsigned i = 0; i < limit; ++i, ++layer )
270  {
271  SetActiveLayer( layer );
272 
273  // Try to guess the type of file by its ext
274  // if it is .drl (KiCad files), .nc or .xnc it is a drill file
275  wxFileName fn( aFileSet[i] );
276  wxString ext = fn.GetExt();
277 
278  if( ext == DrillFileExtension || // our Excellon format
279  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
280  LoadExcellonFiles( aFileSet[i] );
281  else if( ext == GerberJobFileExtension )
282  LoadGerberJobFile( aFileSet[i] );
283  else
284  LoadGerberFiles( aFileSet[i] );
285  }
286  }
287 
288  Zoom_Automatique( true ); // Zoom fit in frame
289 
290  return true;
291 }
292 
293 
295 {
297 
298  if( aCfg->m_Window.grid.sizes.empty() )
299  {
300  aCfg->m_Window.grid.sizes = { "100 mil",
301  "50 mil",
302  "25 mil",
303  "20 mil",
304  "10 mil",
305  "5 mil",
306  "2.5 mil",
307  "2 mil",
308  "1 mil",
309  "0.5 mil",
310  "0.2 mil",
311  "0.1 mil",
312  "5.0 mm",
313  "2.5 mm",
314  "1.0 mm",
315  "0.5 mm",
316  "0.25 mm",
317  "0.2 mm",
318  "0.1 mm",
319  "0.05 mm",
320  "0.025 mm",
321  "0.01 mm" };
322  }
323 
324  if( aCfg->m_Window.zoom_factors.empty() )
325  {
327  }
328 
329  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
330  wxCHECK( cfg, /*void*/ );
331 
334 
335  PAGE_INFO pageInfo( wxT( "GERBER" ) );
336  pageInfo.SetType( cfg->m_Appearance.page_type );
337  SetPageSettings( pageInfo );
338 
341 
345 }
346 
347 
349 {
351 
352  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
353  wxCHECK( cfg, /*void*/ );
354 
359 
363 
364  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
365  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
366 }
367 
368 
370 {
371  wxWindowUpdateLocker no_update( m_LayersManager );
372 
376 
377  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
378  wxSize bestz = m_LayersManager->GetBestSize();
379  bestz.x += 5; // gives a little margin
380 
381  lyrs.MinSize( bestz );
382  lyrs.BestSize( bestz );
383  lyrs.FloatingSize( bestz );
384 
385  if( lyrs.IsDocked() )
386  m_auimgr.Update();
387  else
388  m_LayersManager->SetSize( bestz );
389 
390  syncLayerWidget();
391 }
392 
393 
394 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
395 {
396  bool dcodes_changed = false;
397 
398  switch( aLayerID )
399  {
400  case LAYER_DCODES:
401  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
402  m_DisplayOptions.m_DisplayDCodes = aNewState;
403  break;
404 
406  {
408 
409  auto view = GetCanvas()->GetView();
410 
412  {
413  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
414 
415  // GetLayerPolarity() returns true for negative items
416  return ( item && item->GetLayerPolarity() );
417  } );
418 
419  break;
420  }
421 
423  m_showBorderAndTitleBlock = aNewState;
424 
425  // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
426  // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
428  break;
429 
430  case LAYER_GERBVIEW_GRID:
431  SetGridVisibility( aNewState );
432  break;
433 
434  default:
435  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d",
436  aLayerID ) );
437  }
438 
439  if( dcodes_changed )
440  {
441  auto view = GetCanvas()->GetView();
442 
443  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
444  {
445  int layer = GERBER_DRAW_LAYER( i );
446  int dcode_layer = GERBER_DCODE_LAYER( layer );
447  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
448  }
449  }
450 
452  m_LayersManager->SetRenderState( aLayerID, aNewState );
453 }
454 
455 
457 {
458  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
459  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
462 
464 }
465 
466 
468 {
469  int layer = aLayer;
470 
471  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
472  {
473  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
474 
475  if( gerber == nullptr ) // this graphic layer is available: use it
476  return layer;
477 
478  ++layer; // try next graphic layer
479 
480  if( layer >= (int)ImagesMaxCount() )
481  layer = 0;
482  }
483 
484  return NO_AVAILABLE_LAYERS;
485 }
486 
487 
489 {
491 }
492 
493 
494 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
495 {
496  if( aRebuildLayerBox )
498 
499  m_SelLayerBox->SetSelection( GetActiveLayer() );
500 
501  int dcodeSelected = -1;
503 
504  if( gerber )
505  dcodeSelected = gerber->m_Selected_Tool;
506 
507  if( m_DCodeSelector )
508  {
510  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
511  m_DCodeSelector->Enable( gerber != nullptr );
512  }
513 }
514 
515 
517 {
518  auto remapping = GetImagesList()->SortImagesByZOrder();
519 
521  syncLayerBox( true );
522 
523  std::unordered_map<int, int> view_remapping;
524 
525  for( auto it : remapping )
526  {
527  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
528  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
529  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
530  }
531 
532  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
533  GetCanvas()->Refresh();
534 }
535 
536 
538 {
539  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
540  aOptions.m_DisplayFlashedItemsFill );
541  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
542  aOptions.m_DisplayLinesFill );
543  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
544  aOptions.m_DisplayPolygonsFill );
545 
546  m_DisplayOptions = aOptions;
547 
549 
550  auto view = GetCanvas()->GetView();
551 
552  if( update_flashed )
553  {
555  {
556  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
557 
558  switch( item->m_Shape )
559  {
560  case GBR_SPOT_CIRCLE:
561  case GBR_SPOT_RECT:
562  case GBR_SPOT_OVAL:
563  case GBR_SPOT_POLY:
564  case GBR_SPOT_MACRO:
565  return true;
566 
567  default:
568  return false;
569  }
570  } );
571  }
572  else if( update_lines )
573  {
574  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
575  {
576  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
577 
578  switch( item->m_Shape )
579  {
580  case GBR_CIRCLE:
581  case GBR_ARC:
582  case GBR_SEGMENT:
583  return true;
584 
585  default:
586  return false;
587  }
588  } );
589  }
590  else if( update_polygons )
591  {
592  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
593  {
594  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
595 
596  return ( item->m_Shape == GBR_POLYGON );
597  } );
598  }
599 
600  view->UpdateAllItems( KIGFX::COLOR );
601  GetCanvas()->Refresh();
602 }
603 
604 
606 {
608 
609  // Display the gerber filename
610  if( gerber == nullptr )
611  {
612  SetTitle( _("Gerber Viewer") );
613 
614  SetStatusText( wxEmptyString, 0 );
615 
616  wxString info;
617  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
618  m_TextInfo->SetValue( info );
619 
620  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
621  m_auimgr.Update();
622 
623  ClearMsgPanel();
624  return;
625  }
626  else
627  {
628  wxString title;
629  wxFileName filename( gerber->m_FileName );
630 
631  title = filename.GetFullName();
632 
633  if( gerber->m_IsX2_file )
634  title += wxS( " " ) + _( "(with X2 attributes)" );
635 
636  title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
637  SetTitle( title );
638 
639  gerber->DisplayImageInfo( this );
640 
641  // Display Image Name and Layer Name (from the current gerber data):
642  wxString status;
643  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
644  gerber->m_ImageName,
645  gerber->GetLayerParams().m_LayerName );
646  SetStatusText( status, 0 );
647 
648  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
649  wxString info;
650  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
651  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
652  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
653  gerber->m_FmtScale.x,
654  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
655  gerber->m_FmtScale.y,
656  gerber->m_NoTrailingZeros ? 'T' : 'L' );
657 
658  if( gerber->m_IsX2_file )
659  info << wxT(" ") << _( "X2 attr" );
660 
661  m_TextInfo->SetValue( info );
662 
663  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
664  m_auimgr.Update();
665  }
666 }
667 
668 
669 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
670 {
671  switch( aLayerID )
672  {
675  case LAYER_GERBVIEW_GRID: return IsGridVisible();
677  case LAYER_GERBVIEW_BACKGROUND: return true;
678 
679  default:
680  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d",
681  aLayerID ) );
682  }
683 
684  return true;
685 }
686 
687 
689 {
690  LSET visible = LSET::AllLayersMask();
691 
692  if( GetCanvas() )
693  {
694  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
695  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
696  }
697 
698  return visible;
699 }
700 
701 
703 {
704  if( GetCanvas() )
705  {
706  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
707  {
708  bool v = aLayerMask[i];
709  int layer = GERBER_DRAW_LAYER( i );
710  GetCanvas()->GetView()->SetLayerVisible( layer, v );
713  }
714  }
715 }
716 
717 
718 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
719 {
720  return m_LayersManager->IsLayerVisible( aLayer );
721 }
722 
723 
725 {
726  COLOR4D color = COLOR4D::UNSPECIFIED;
727  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
728 
729  switch( aLayerID )
730  {
732  case LAYER_DCODES:
735  color = settings->GetColor( aLayerID );
736  break;
737 
738  case LAYER_GERBVIEW_GRID:
739  color = GetGridColor();
740  break;
741 
742  default:
743  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d",
744  aLayerID ) );
745  }
746 
747  return color;
748 }
749 
750 
752 {
755 }
756 
757 
759 {
760  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
761 
762  switch( aLayerID )
763  {
765  case LAYER_DCODES:
766  settings->SetColor( aLayerID, aColor );
767  break;
768 
770  settings->SetColor( LAYER_GERBVIEW_DRAWINGSHEET, aColor );
771  // LAYER_DRAWINGSHEET color is also used to draw the drawing-sheet
772  // FIX ME: why LAYER_DRAWINGSHEET must be set, although LAYER_GERBVIEW_DRAWINGSHEET
773  // is used to initialize the drawing-sheet color layer.
774  settings->SetColor( LAYER_DRAWINGSHEET, aColor );
775  break;
776 
777  case LAYER_GERBVIEW_GRID:
778  SetGridColor( aColor );
779  settings->SetColor( aLayerID, aColor );
780  break;
781 
783  SetDrawBgColor( aColor );
784  settings->SetColor( aLayerID, aColor );
785  break;
786 
787  default:
788  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d",
789  aLayerID ) );
790  }
791 }
792 
793 
795 {
798  else
799  return GetDrawBgColor();
800 }
801 
802 
804 {
805  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
806 }
807 
808 
809 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
810 {
811  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
813 }
814 
815 
816 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
817 {
818  m_activeLayer = aLayer;
819 
820  if( doLayerWidgetUpdate )
821  m_LayersManager->SelectLayer( aLayer );
822 
824 
825  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
826  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
827 
829  GetCanvas()->Refresh();
830 }
831 
832 
833 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
834 {
835  m_paper = aPageSettings;
836 
837  if( GetScreen() )
838  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
839 
840  GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
841 
842  // Prepare drawing-sheet template
844  &Prj(), &GetTitleBlock() );
845 
846  if( GetScreen() )
847  {
848  drawingSheet->SetPageNumber( "1" );
849  drawingSheet->SetSheetCount( 1 );
850  }
851 
853 
854  // Draw panel takes ownership of the drawing-sheet
855  drawPanel->SetDrawingSheet( drawingSheet );
856 }
857 
858 
860 {
861  return m_paper;
862 }
863 
864 
865 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
866 {
867  // this function is only needed because EDA_DRAW_FRAME is not compiled
868  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
869  // into an application specific source file.
870  return GetPageSettings().GetSizeIU();
871 }
872 
873 
875 {
876  wxASSERT( m_gerberLayout );
877  return m_gerberLayout->GetTitleBlock();
878 }
879 
880 
881 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
882 {
883  wxASSERT( m_gerberLayout );
884  m_gerberLayout->SetTitleBlock( aTitleBlock );
885 }
886 
887 
889 {
890  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_GRID );
891 }
892 
893 
895 {
896  Pgm().GetSettingsManager().GetColorSettings()->SetColor( LAYER_GRID, aColor );
897  GetCanvas()->GetGAL()->SetGridColor( aColor );
898  m_gridColor = aColor;
899 }
900 
901 
903 {
904  wxString line;
905 
906  line.Printf( "grid X %s Y %s",
907  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
908  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
909 
910  SetStatusText( line, 4 );
911 }
912 
913 
915 {
917 
918  if( !GetScreen() )
919  return;
920 
921  wxString line;
923 
924  if( GetShowPolarCoords() ) // display relative polar coordinates
925  {
926  double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
927  double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
928  double theta = RAD2DEG( atan2( -dy, dx ) );
929  double ro = hypot( dx, dy );
930 
931  line.Printf( wxT( "r %s theta %s" ),
932  MessageTextFromValue( GetUserUnits(), ro, false ),
933  MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) );
934 
935  SetStatusText( line, 3 );
936  }
937 
938  // Display absolute coordinates:
939  line.Printf( wxT( "X %s Y %s" ),
940  MessageTextFromValue( GetUserUnits(), cursorPos.x, false ),
941  MessageTextFromValue( GetUserUnits(), cursorPos.y, false ) );
942  SetStatusText( line, 2 );
943 
944  if( !GetShowPolarCoords() )
945  {
946  // Display relative cartesian coordinates:
947  double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
948  double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
949 
950  line.Printf( wxT( "dx %s dy %s dist %s" ),
951  MessageTextFromValue( GetUserUnits(), dXpos, false ),
952  MessageTextFromValue( GetUserUnits(), dYpos, false ),
953  MessageTextFromValue( GetUserUnits(), hypot( dXpos, dYpos ), false ) );
954  SetStatusText( line, 3 );
955  }
956 
957  DisplayGridMsg();
958 }
959 
960 
962 {
963  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
964 }
965 
966 
968 {
970 }
971 
972 
974 {
975  // Called on units change (see EDA_DRAW_FRAME)
979 }
980 
981 
983 {
985 
986  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
987 
988  if( m_toolManager )
989  {
991  GetCanvas()->GetViewControls(), config(), this );
993  }
994 
996 
998 
999  galCanvas->GetView()->RecacheAllItems();
1000  galCanvas->SetEventDispatcher( m_toolDispatcher );
1001  galCanvas->StartDrawing();
1002 
1005 
1007  ReCreateMenuBar();
1008 }
1009 
1010 
1012  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1013 {
1014  wxTreebook* book = aParent->GetTreebook();
1015 
1016  book->AddPage( new wxPanel( book ), _( "GerbView" ) );
1017  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
1018  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1019 
1020  aHotkeysPanel->AddHotKeys( GetToolManager() );
1021 }
1022 
1023 
1024 
1026 {
1027  // Create the manager and dispatcher & route draw panel events to the dispatcher
1030  GetCanvas()->GetViewControls(), config(), this );
1031  m_actions = new GERBVIEW_ACTIONS();
1033 
1034  // Register tools
1042 
1043  // Run the selection tool, it is supposed to be always active
1044  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1045 }
1046 
1047 
1049 {
1051 
1053  EDITOR_CONDITIONS cond( this );
1054 
1055  wxASSERT( mgr );
1056 
1057 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1058 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
1059 
1061  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
1065  CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
1066 
1070 
1072  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
1074  CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
1076  CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1077 
1078  auto flashedDisplayOutlinesCond =
1079  [this] ( const SELECTION& )
1080  {
1082  };
1083 
1084  auto linesFillCond =
1085  [this] ( const SELECTION& )
1086  {
1088  };
1089 
1090  auto polygonsFilledCond =
1091  [this] ( const SELECTION& )
1092  {
1094  };
1095 
1096  auto negativeObjectsCond =
1097  [this] ( const SELECTION& )
1098  {
1100  };
1101 
1102  auto dcodeCond =
1103  [this] ( const SELECTION& )
1104  {
1105  return IsElementVisible( LAYER_DCODES );
1106  };
1107 
1108  auto diffModeCond =
1109  [this] ( const SELECTION& )
1110  {
1112  };
1113 
1114  auto highContrastModeCond =
1115  [this] ( const SELECTION& )
1116  {
1118  };
1119 
1120  auto flipGerberCond =
1121  [this] ( const SELECTION& )
1122  {
1124  };
1125 
1126  auto layersManagerShownCondition =
1127  [this] ( const SELECTION& aSel )
1128  {
1130  };
1131 
1133  CHECK( flashedDisplayOutlinesCond ) );
1135  mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1136  mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1137  mgr->SetConditions( GERBVIEW_ACTIONS::dcodeDisplay, CHECK( dcodeCond ) );
1138  mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
1139  mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1140  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1142  CHECK( layersManagerShownCondition ) );
1143 
1144 #undef CHECK
1145 #undef ENABLE
1146 }
1147 
1148 
1149 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1150 {
1151  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1152 
1153  RecreateToolbars();
1154  Layout();
1155  SendSizeEvent();
1156 }
1157 
1158 
1160 {
1161  return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1162 }
1163 
1164 
1166 {
1168 
1169  // show/hide auxiliary Vertical layers and visibility manager toolbar
1170  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1171  m_auimgr.Update();
1172 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
A list of GERBER_DRAW_ITEM objects currently loaded.
Definition: gbr_layout.h:45
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
wxString m_LayerName
wxSize GetBestSize() const
Return the preferred minimum size, taking into consideration the dynamic content.
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
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 drawing sheet item colors.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
SETTINGS_MANAGER * GetSettingsManager() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void UpdateStatusBar() override
Update the status bar information.
void DeleteAllImages()
Remove all loaded data in list, and delete all images, freeing the memory.
ACTION_TOOLBAR * m_auxiliaryToolBar
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
This is usually the background color, but can be another color in order to see negative objects.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
virtual void SetScreen(BASE_SCREEN *aScreen)
COLOR4D GetVisibleElementColor(int aLayerID)
Return the color of a gerber visible element.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
static TOOL_ACTION zoomTool
Definition: actions.h:99
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
FILE_HISTORY m_jobFileHistory
void SetPageSettings(const PAGE_INFO &aPageSettings) override
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
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:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
wxSize m_FmtLen
Image rotation (0, 90, 180, 270 only) in degrees.
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
void SetDCodeSelection(int aDCodeId)
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
void 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:141
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.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=nullptr)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: ui_common.cpp:112
FILE_HISTORY m_zipFileHistory
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:71
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:46
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
Master controller class:
Definition: tool_manager.h:54
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
static TOOL_ACTION measureTool
Definition: actions.h:154
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
static TOOL_ACTION flipGerberView
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Display information about image parameters in the status bar.
bool m_DiffMode
Display layers in diff mode.
Item needs to be redrawn.
Definition: view_item.h: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 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:572
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:140
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:144
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
static TOOL_ACTION linesDisplayOutlines
GBR_DISPLAY_OPTIONS m_DisplayOptions
void applyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
static TOOL_ACTION togglePolarCoords
Definition: actions.h:149
ACTIONS * m_actions
Definition: tools_holder.h:159
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:63
Definition of file extensions used in Kicad.
Base window classes and related definitions.
bool IsElementVisible(int aLayerID) const
Test whether a given element category is visible.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
GBR_LAYOUT * m_gerberLayout
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:787
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
Definition: view.cpp:682
Abstract functions of LAYER_WIDGET so they may be tied into the GERBVIEW_FRAME's data and we can add ...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define ZOOM_LIST_GERBVIEW
Definition: zoom_defines.h:29
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:105
Handle actions that are shared between different applications.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
void StartDrawing()
Begin drawing if it was stopped previously.
SELECTION_CONDITION PolarCoordinates()
Create a functor testing if polar coordinates are current being used.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static TOOL_ACTION milsUnits
Definition: actions.h:145
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
Handles action that are shared between different applications.
Definition: common_tools.h:37
static TOOL_ACTION flashedDisplayOutlines
GBR_LAYOUT * GetGerberLayout() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
void DisplayGridMsg() override
Display the current grid pane on the status bar.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(LAYER_NUM aLayer)
Return the visible state of the layer ROW associated with aLayer id.
void ReFill()
Rebuild Render for instance after the config is read.
COLOR4D GetColor(int aLayer) const
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:85
wxStaticText * m_cmpText
int GetActiveLayer() const
Return the active layer.
Selection tool for GerbView, based on the one in Pcbnew.
wxChoice * m_SelAperAttributesBox
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
see class PGM_BASE
void LoadColors(const COLOR_SETTINGS *aSettings) override
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
std::vector< wxString > m_ZipFileHistory
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Set or update the drawing-sheet (borders and title block) used by the draw panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void setupUnits(APP_SETTINGS_BASE *aCfg)
#define DEFAULT_FILE_HISTORY_SIZE
IDs range for menuitems file history: The default range file history size is 9 (compatible with defau...
Definition: id.h:69
static TOOL_ACTION polygonsDisplayOutlines
COLOR4D GetLayerColor(int aLayer) const
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:41
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
#define IU_PER_MILS
Definition: plotter.cpp: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:199
void syncLayerWidget()
Update the currently "selected" layer within the GERBER_LAYER_WIDGET.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxChoice * m_SelComponentBox
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
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:54
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
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()
Rebuild Render for instance after the config is read.
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Recreates the menu bar.
wxStaticText * m_apertText
int getNextAvailableLayer(int aLayer=0) const
Find the next empty layer starting at aLayer and returns it to the caller.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
BASE_SCREEN class implementation.
Message panel definition file.
void SetRenderState(int aId, bool isSet)
Set the state of the checkbox associated with aId within the Render tab group of the widget.
void SetLayout(GBR_LAYOUT *aLayout)
Set the m_gerberLayout member in such as way as to ensure deleting any previous GBR_LAYOUT.
bool IsLayerVisible(int aLayer) const
Test whether a given layer is visible.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
static TOOL_ACTION highContrastMode
Definition: actions.h:103
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
Rendering engine changes.
Definition: tool_base.h:81
void SelectLayer(LAYER_NUM aLayer)
Change the row selection in the layer list to aLayer provided.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetElementVisibility(int aLayerID, bool aNewState)
Change the visibility of an element category.
const wxString GetDisplayName(int aIdx, bool aNameOnly=false, bool aFullName=false)
Get the display name for the layer at aIdx.
virtual void SetGridVisibility(bool aVisible)
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void UpdateTitleAndInfo()
Display the short filename (if exists) of the selected layer on the caption of the main GerbView wind...
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:153
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
GERBER_LAYER & GetLayerParams()
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
const std::string DrillFileExtension
Handle actions that are shared between different frames in Pcbnew.
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:64
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)